Gra*_*y-M 5 android listview cursor
我正在尝试使用ContextMenu。我已经使用SimpleCursorAdapter为一个简单的ListActivity成功完成了此操作。
继续,我想用CursorAdapter替换SimpleCursorAdapter,但仍然保留ContextMenu的行为,因此我添加了两个强制性重写功能bindView和newView
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view = mLayoutInflater.inflate(R.layout.check_row, parent, false);
registerForContextMenu(view);
return view;
}
Run Code Online (Sandbox Code Playgroud)
请注意registerForContextMenu,它取代了ListActivity的onCreate方法中的registerForContextMenu(getListView())。我发现有必要调用onCreateContextMenu(...)
除提供给onCreateContextMenu(...)的ContextMenuInfo参数外,所有这些工作(使用预期的小部件创建的行,其上的回调正常工作等)现在为空-阻止我访问rowId。
还有另一个技巧可以执行-也许在CursorAdapter的bindView(...)方法中?
我正在回答这个问题 - 但我想指出“commonsware.com”提供了线索和方向,见上文。
问题
我采用的解决方案执行以下操作
| 归档时间: |
|
| 查看次数: |
3469 次 |
| 最近记录: |