BaseAdapter和ArrayAdapter的用法区别区别、BaseAdapter、ArrayAdapter

2023-09-12 07:01:13 作者:自强不息

我想用要知道其中的差别 BaseAdapter ArrayAdapter ,显然我不明白其中可实施的时候,因为我已经实现我想要什么,通过 ArrayAdapters 。你能不能让我更多地了解这一点。请。

I want to know the difference using BaseAdapter and ArrayAdapter, clearly i don't understand which to implement when, as i have been achieving what i want, through ArrayAdapters. Can you make me know more about this. Please.

此外,没有它影响到的ListView的性能,其上适配器接口我实现?

Also, does it affects the performance of the ListView, on which adapter interface i implement ?

和,最后一个问题是,我可以实现任何与的ListView 使用其中任何适配器,或做,也有一定的情况下,特定​​的适配器只可以用吗?

And, the last question is, can i achieve anything doing with ListView using any of these Adapters, or, there are certain cases where specific adapter only can be used ?

推荐答案

下面的区别是:

BaseAdapter 是一个非常通用的适配器,允许你做pretty的多少随便你。但是,你必须做一些更多的编码自己搞不定。 ArrayAdapter 是一个更完整的实现,很适合在数组或的ArrayList s的数据。同样,还有一个相关的的CursorAdapter ,你应该使用,如果你的数据在光标。这两个延伸 BaseAdapter BaseAdapter is a very generic adapter that allows you to do pretty much whatever you want. However, you have to do a bit more coding yourself to get it working. ArrayAdapter is a more complete implementation that works well for data in arrays or ArrayLists. Similarly, there is a related CursorAdapter that you should use if your data is in a Cursor. Both of these extend BaseAdapter.

如果你的数据是在一个专门收藏某一类,或者如果您不想在默认行为 ArrayAdapter 提供,你可能会想扩展 BaseAdapter 来得到你所需要的灵活性。

If your data is in a specialized collection of some sort or if you don't want the default behavior that ArrayAdapter provides, you will likely want to extend BaseAdapter to get the flexibility you need.

每个的表现真的取决于你如何实现它们或改变自己的行为。在他们的核心,其中之一可以是一样有效(尤其是考虑到一个 ArrayAdapter 的是的一个 BaseAdapter )。

The performance of each really depends on how you implement them or change their behavior. At their core, either one can be just as effective (especially considering that an ArrayAdapter is a BaseAdapter).

您可以做pretty的很多你想做的任何适配器,但请记住, BaseAdapter 是抽象的,所以你不能直接使用它。

You can do pretty much whatever you want with any adapter, but keep in mind that BaseAdapter is abstract, so you can't use it directly.