问题描述
林看着这ListView的教程:
Im looking at this ListView Tutorial:
和我想知道好多是如何创建自己的ArrayAdapter,而不是仅仅使用和ArrayAdapter。
and I was wondering how much better is to create my own ArrayAdapter, rather than just using and ArrayAdapter.
在它定义了一个StableArrayAdapter教程,究竟是什么意思吗?如果我使用一个普通arrayAdapter它可能是危险的因为某些原因?
In the Tutorial it defines a "StableArrayAdapter", what exactly does this means? if i use a regular arrayAdapter it could be dangerous for some reason?
推荐答案
ArrayAdapter:这仅仅是一种方式来提供数据到ListView。这也是由对象的数组支持的BaseAdapter。
ArrayAdapter: It is merely a way to provide data to a ListView. It is also a BaseAdapter that is backed by an array of objects.
CustomAdapter:如果您的ListView控件是一个正常的,简单的ListView(其中您有列表中的每件商品的TextView的),那么使用ArrayAdapter将是贴切的。
但是建议你创建自己的CustomAdapter延伸,你可以使用你的ListView提供数据的ArrayAdapter。这样,您就可以轻松地扩展您的ListView包括不止一个TextView的,甚至ImageView的(显示图像)。
CustomAdapter: If if your ListView is a normal and simple ListView (wherein you are having one TextView per item in the list), then the use of ArrayAdapter would be apt.But it is recommended you to create your own CustomAdapter which extends an ArrayAdapter that you can use for providing data to your ListView. This way you can easily extend your ListView to include more that one TextView or even ImageView (to show images).
的CursorAdapter:当你在一个光标(通常,当你从数据库中检索数据有数据光标适配器时使用的光标必须包含一个名为_id列或本级将无法工作。
CursorAdapter: Cursor Adapter is used when you have Data in a Cursor (typically when you are retrieving data from a database. The Cursor must include a column named "_id" or this class will not work.
这篇关于StableArrayAdapter VS ArrayAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!