扩展Activity和扩展ListActivity有什么区别? [英] What are the differences between extending Activity and extending ListActivity?
问题描述
我正在使用一个扩展Activity的类来从API获取列表...
I am using a class which extends Activity to obtain a list from an API...
在一些基本相同的应用中,开发人员扩展了ListActivity ...
In some apps which do basically the same, the devs extended ListActivity...
有哪些区别?
推荐答案
ListActivity
通过提供一些免费"的以列表为中心的功能扩展了常见的android.app.Activity
的功能.例如,列表条目单击的处理完全包含在ListActivity的onListItemClick(...)
中,而如果使用的是普通android.app.Activity
,则需要使用OnClickListener
和实现手动实现.
ListActivity
extends the functionality of the common android.app.Activity
by providing a number of list centric features 'for-free' if you like. For example, the handling of a list entry click is neatly contained within ListActivity's onListItemClick(...)
whereas if you were using a plain android.app.Activity
then you would need to implement this manually with an OnClickListener
and implementation.
对于所有帐户,如果布局包含列表,则使用ListActivity/ListFragment,因为它是有用的扩展.这并不意味着您的整个屏幕布局都必须是列表,而是其中的一部分必须托管一个标识符为id="@android:id/list"
的ListView小部件.
By all accounts, if your layout contains a list then use a ListActivity/ListFragment since it is a useful extension. It does not mean your whole screen layout has to be list but a portion of it has to host a ListView widget with identifier, id="@android:id/list"
.
可以在此处找到有关该类的Javadoc以及有关如何使用它的有用示例.
The Javadoc on the class with useful examples of how to use it can be found here.
这篇关于扩展Activity和扩展ListActivity有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!