Add multiple listings to one activity

I want to add several lists, as one twitter application for android: But eveytime I try to add several lists in XML and populate it, this is only the first of them. Do you have an explanation?

+1
source share
2 answers

Try the following:

<LinearLayout android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">

<ListView android:id="@+id/list1"
      android:layout_height="0"
      android:layout_width="fill_parent"
      android:layout_weight="1" />

<ListView android:id="@+id/list2"
      android:layout_height="0"
      android:layout_width="fill_parent"
      android:layout_weight="1" />

</LinearLayout>

You can put any number of lists as long as you determine the height of each of them is 0 and weight 1. Hope this helps. Enjoy!

+1
source

I don’t know how this Twitter application works, but it can be easily done with fragments. Subclass ListFragmentand then add as many fragments as you want in your activity.

0

All Articles