简体   繁体   English

Android ListAdapter,ArrayAdapter

[英]Android ListAdapter, ArrayAdapter

I want to know what is a ListAdapter and ArrayAdapter ? 我想知道什么是ListAdapterArrayAdapter Also, I am so confused about the fact that I can set a type ListAdapter to be constructed using ArrayAdapter as shown below. 另外,我很困惑的事实,我可以设置一个类型ListAdapter使用被构造ArrayAdapter如下所示。

ListAdapter theAdapter = new ArrayAdapter<String>()

How can this be? 怎么会这样? How can a ListAdapter be constructed using the constructor of an ArrayAdapter ? 如何使用ArrayAdapter的构造函数构造ListAdapter

ListAdapter is an interface,see here . ListAdapter是一个接口,请参见此处

BaseAdapter is an class implemented ListAdapter interface,see here . BaseAdapter是实现ListAdapter接口的类,请参见此处

And ArrayAdapter is subclass of BaseAdapter ,see here ; ArrayAdapterBaseAdapter子类,请参见此处

So we can write a code like this: 因此我们可以编写如下代码:

ListAdapter theAdapter = new ArrayAdapter();

Just like 就像

View.OnClickListener listener = new A();//A implements OnClickListener interface

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM