问题描述
什么是的CursorAdapter
之间的确切差异, ResourceCursorAdapter
What is the exact difference between CursorAdapter
andResourceCursorAdapter
?
有人可以解释什么是需要覆盖
API的
当实现我自己的 ResourceCursorAdapter
Can somebody explain what are the api's that are required to override
when implementing my own ResourceCursorAdapter
?
我已经通过 ResourceCursorAdapter
文档,并能去
要弄清楚,它的构造函数需要一个额外的布局
参数相比的CursorAdapter
构造函数。但我不能
了解什么是具有额外布局的意义
参数 ResourceCusorAdapter
构造。
I have gone through the ResourceCursorAdapter
documentation and ableto figure out that it's constructor takes an additional layoutparameter as compared to CursorAdapter
constructor. But I am unable tounderstand what is the significance of having an additional layoutparameter in ResourceCusorAdapter
constructor.
推荐答案
并ResourceCursorAdapter是抽象类。确切的差别在于ResourceCursorAdapter实现的 NewView的的方法(该方法是在基CursorAdapter的摘要)。
Both CursorAdapter and ResourceCursorAdapter are abstract classes. The exact difference is that ResourceCursorAdapter implements the newView method (which is abstract in the base CursorAdapter).
ResourceCursorAdapter也覆盖的 newDropDownView 的方法有所不同,但是这还不是最主要的,主要的是的 NewView的的。
ResourceCursorAdapter also overrides the newDropDownView method differently, but that's not the main thing, the main thing is newView.
在构造函数中额外的布局是用于创建每个项目的看法,这里是的 NewView的的ResourceCursorAdapter from源:
The extra layout in the constructor is what is used to create the view for each item, here is the newView method of ResourceCursorAdapter from the source:
/**
* Inflates view(s) from the specified XML file.
*
* @see android.widget.CursorAdapter#newView(android.content.Context,
* android.database.Cursor, ViewGroup)
*/
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return mInflater.inflate(mLayout, parent, false);
}
基本上,如果你不使用ResourceCursorAdapter,你做很多同样在CursorAdapter的你自己定制的实现。你可以自由地做多,当然,但如果你有一组布局更容易扩展ResourceCursorAdapter(它增添了几分便利,这是所有)。
Basically, if you don't use ResourceCursorAdapter, you do much the same in your own custom implementation of CursorAdapter. You're free to do more, of course, but if you have a set layout it's easier to extend ResourceCursorAdapter (it adds a bit of convenience, that's all).
这篇关于CursorAdapter的VS ResourceCursorAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!