如何使我的ListActivitity要与应用程序兼容性兼容使我、兼容性、应用程序、ListActivitity

2023-09-07 01:54:35 作者:叹一曲悠悠

我建立一个Android应用程序,我试图让它使用程序兼容性库API级别10兼容。正常的活动都没有问题,但使用的是什么曾经是 ListActivity (现从 ActionBarActivitity 扩展),我得到的问题时, setListAdapter(适配器)的ListView 有关的方法。

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.

我能做些什么让我的 ListActivitity 要与程序兼容性

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

推荐答案

从支持库的http://developer.android.com/reference/android/support/v4/app/ListFragment.html

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

您可以使用 AppCompact 并延长 ActionBarActivity 。在 ListFragment 您可以使用 setListAdapter(适配器)

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

如果你不想 ListFrament 你可以有一个列表视图在活动布局,布局设置为活动中,初始化它的活动,并设置适配器的ListView

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.