BaseAdapter和ArrayAdapter有什么区别? [英] What's the difference between BaseAdapter and ArrayAdapter?

查看:104
本文介绍了BaseAdapter和ArrayAdapter有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用BaseAdapterArrayAdapter的区别.

I want to know the difference between using BaseAdapter and ArrayAdapter.

我一直在通过ArrayAdapters实现我想要的.

I have been achieving what I want through ArrayAdapters.

它会影响ListView在实现它的适配器接口上的性能吗?

Does it affect the performance of the ListView on the adapter interface in which it is implemented ?

最后一个问题是,我可以使用这些Adapters中的任何一个来实现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是一个非常通用的适配器,可让您执行几乎所有您想做的事情.但是,您需要自己编写一些代码才能使其正常工作.
  • ArrayAdapter是一个更完整的实现,非常适合数组或ArrayList中的数据.同样,如果数据位于Cursor中,则应使用相关的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).

您可以使用任何适配器执行几乎任何您想做的事,但是请记住,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.

这篇关于BaseAdapter和ArrayAdapter有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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