开发者

add multiple listview in one activity

I want to add multiple listview like one app for twitter for android : link But eveytime i tr开发者_JS百科y to add multiple listview in the XML and populate it there is just the first one that appear . Do you have an explanation ?


Try this:

<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 listviews as long as you define the height of each to be 0 and weight 1. Hope that helps. Have fun!


I don't know how that twitter app works, but this can be easily done using fragments. Subclass ListFragment and then add as many fragments as you want in your Activity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜