質問

I have two buttons in my layout say b1 and b2. By pressing b1 I want to populate the list using listview. By pressing b2 I want to populate the list using expandablelistview. I am passing different sets of data on these listviews. My question is, is it possible to use listview and expandable listview in the same xml file? If its possible, then how can it be done?

役に立ちましたか?

解決

Yes, it is very much possible.

Try this code here. It should work fine.

list = (ListView) findViewById(R.id.list);
list.setAdapter(myListAdpater);


expList = (ExpandableListView)findViewById(R.id.expList);
expList.setAdapter(myExpListAdapter);

Note : No need to extend ExpandableListActivity or ListActivity in your class.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top