views:

16

answers:

0

Hi guys,

I have two list, that need to be processed and displayed, I have used the following technique -

I get the data from 2 sources, process it and have 2 Custom Adapters, that take the data and place it in the relvant View.

However I only can view one list (the one at the top of in the view xml) - and not the other one,

Can someone please help me fix this prob. Its driving me insane.

Main Activity code belwo:

enter code here     public class TestList extends Activity {
   private final static String TAG = "ListSample";
   private List<String> items;
   private List<String> items2;
   private CustomTeamListAdapter m_adapter;
   private CustomTeamListAdapterTwo t_adapter;

   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      items = new ArrayList<String>();
      for (int i = 0; i < 20; i++) {
         items.add(i + "|||>>");
      }
      ListView list = (ListView) findViewById(R.id.customlist);
      this.m_adapter = new CustomTeamListAdapter(this, R.layout.listitem,
            (ArrayList<String>) items);
      list.setAdapter(m_adapter);


      /******************************************************************************/

      items2 = new ArrayList<String>();
      for (int i = 0; i < 20; i++) {
         items2.add(i + ">>----");
      }

      ListView list_two = (ListView) findViewById(R.id.customlisttwo);
      this.t_adapter = new CustomTeamListAdapterTwo(this, R.layout.listitem,
            (ArrayList<String>) items2);
      list_two.setAdapter(t_adapter);

   }


   private class CustomTeamListAdapter extends ArrayAdapter<String> {

      private ArrayList<String> items;

      public CustomTeamListAdapter(Context context, int textViewResourceId,
            ArrayList<String> items) {
         super(context, textViewResourceId, items);
         this.items = items;
      }

      public View getView(int position, View convertView, ViewGroup parent) {
         View v = convertView;
         LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         v = vi.inflate(R.layout.listitem, null);

         String o = items.get(position);
         if (o != null) {

            TextView tt = (TextView) v.findViewById(R.id.sampletext);
            tt.setText(o + "FirstSet");
            tt.setId(position);
         }
         return v;
      }
   }

   private class CustomTeamListAdapterTwo extends ArrayAdapter<String> {

      private ArrayList<String> items;

      public CustomTeamListAdapterTwo(Context context, int textViewResourceId,
            ArrayList<String> items) {
         super(context, textViewResourceId, items);
         this.items = items;
      }

      public View getView(int position, View convertView, ViewGroup parent) {
         View v = convertView;
         LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         v = vi.inflate(R.layout.listitem, null);

         String o = items.get(position);
         if (o != null) {

            TextView tt = (TextView) v.findViewById(R.id.sampletext);
            tt.setText(o + "SecondSet");
            tt.setId(position);
         }
         return v;
      }
   }

}

Main layout XML below

enter code here    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="fill_parent"
   android:layout_height="fill_parent">

   <ListView android:id="@+id/customlisttwo"
      android:layout_width="fill_parent" android:layout_height="wrap_content" />

   <TextView android:id="@+id/randomtext" android:layout_width="fill_parent"
      android:layout_height="wrap_content" android:background="#CCCCCC"
      android:text="Random Text" />

   <ListView android:id="@+id/customlist" android:layout_width="fill_parent"
      android:layout_height="wrap_content" />

</LinearLayout>

Item Layout

enter code here    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="fill_parent"
   android:layout_height="fill_parent">

   <ListView android:id="@+id/customlisttwo"
      android:layout_width="fill_parent" android:layout_height="wrap_content" />

   <TextView android:id="@+id/randomtext" android:layout_width="fill_parent"
      android:layout_height="wrap_content" android:background="#CCCCCC"
      android:text="Random Text" />

   <ListView android:id="@+id/customlist" android:layout_width="fill_parent"
      android:layout_height="wrap_content" />

</LinearLayout>

Thanks in advance for your thoughts