Chr*_*rry 53 user-interface android adapter
所以,我正在观看此视频http://www.youtube.com/watch?v=N6YdwzAvwOA,而Romain Guy正在展示如何使用该getView()方法制作更高效的UI适配器代码.这是否也适用于CursorAdapters?我正在使用bindView()和newView()我的自定义游标适配器.我应该使用getView吗?
Com*_*are 73
CursorAdapter有一个getView()代表的实现,newView()并bindView()以这种方式强制执行行回收模式.因此,CursorAdapter如果您要覆盖newView()和排除,则不需要对行进行任何特殊操作bindView().
Cro*_*ong 19
/**
* @see android.widget.ListAdapter#getView(int, View, ViewGroup)
*/
public View getView(int position, View convertView, ViewGroup parent) {
if (!mDataValid) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
if (!mCursor.moveToPosition(position)) {
throw new IllegalStateException("couldn't move cursor to position " + position);
}
View v;
if (convertView == null) {
v = newView(mContext, mCursor, parent);
} else {
v = convertView;
}
bindView(v, mContext, mCursor);
return v;
}
Run Code Online (Sandbox Code Playgroud)
这个CursorAdapter源代码,显然是cursorAdapter的工作原理.
| 归档时间: |
|
| 查看次数: |
25991 次 |
| 最近记录: |