Adding Listview in Activity
I want to add ListView as component in my Activity which uses LinearLayout. I tried simple approach as well 开发者_如何学运维as suggestion mentioned in Embedding a sized ListView in activity - android
But app crashes on Android 2.2 emulator. I can not inherit my class from ListActivity because I want to include some more components.
Any help or suggestions is appreciated.
1) Declare ListView
control in xml file which you are setting as contentView
and then do Mapping of that Listview
in your class file.
2) If you don't want to use ListView
in XMl file then use ListActivity
3) If you don't want to use ListActivity
and also Don't want to use ListView
from Xml file then Make a Dynamic ListView
in class file and
set that listView
as contentView
精彩评论