I am building an Android app and I am trying to make it compatible with API level 10 using AppCompat library. Normal activities are no problem but when using what used to be ListActivity (now extends from ActionBarActivitity) I am getting problems with setListAdapter(adapter) and other ListView related methods.

What can I do to make my ListActivitity to be compatible with AppCompat?

有帮助吗?

解决方案

Use a ListFragment from the support library http://developer.android.com/reference/android/support/v4/app/ListFragment.html

You can use AppCompact and extend ActionBarActivity. In ListFragment you can use setListAdapter(adapter).

If you don't want ListFrament you can have a Listview in activity layout, set the layout to the activity, initialize it in Activity and set adapter to ListView.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top