如何使我的ListActivitity要与应用程序兼容性兼容 [英] How to make my ListActivitity to be compatible with AppCompat

查看:151
本文介绍了如何使我的ListActivitity要与应用程序兼容性兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个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?

推荐答案

从支持库的 ListFragment 。 COM /参考/安卓/支持/ V4 /应用/ ListFragment.html rel=\"nofollow\">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.

这篇关于如何使我的ListActivitity要与应用程序兼容性兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆