2 ListAdapter等,在一个Activity中

时间:2012-02-20 19:30:54

标签: android android-layout android-activity android-arrayadapter listadapter

如何在一个活动中添加2个ListAdapter以及更多内容?例如:

enter image description here

1 个答案:

答案 0 :(得分:1)

对于每个列表视图,我会这样做

final String1[] menu1 = {"menu","menu","menu"};
final String2[] menu2 = {"menu","menu","menu"};
final String3[] menu3 = {"menu","menu","menu"};
ListView lv1 = (ListView) findViewById(R.id.listView1);
ListView lv2 = (ListView) findViewById(R.id.listView2);
ListView lv3 = (ListView) findViewById(R.id.listView3);
lv1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu1));
lv2.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu1));
lv3.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu1));