- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试使用上下文菜单。我已经使用 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;
}
请注意 registerForContextMenu 替换了 ListActivity 的 onCreate 方法中的 registerForContextMenu(getListView())。我发现有必要调用 onCreateContextMenu(...)
除了提供给 onCreateContextMenu(...) 的 ContextMenuInfo 参数现在为 null - 阻止我访问 rowId 之外,所有这些都有效(使用预期的小部件创建的行,它们的回调工作等)。
是否还有其他技巧可以执行 - 也许在 CursorAdapter 的 bindView(...) 方法中?
最佳答案
我正在回答这个问题 - 但我要指出“commonsware.com”提供了线索和方向,见上文。
问题
我采用的解决方案做了以下事情
关于android - onCreateContextMenu 被 ContextMenuInfo 的 null 值调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1718765/
我正在尝试使用上下文菜单。我已经使用 SimpleCursorAdapter 为简单的 ListActivity 成功完成了此操作。 继续我想用 CursorAdapter 替换 SimpleCurs
在 onCreate 中,我将线性布局 View 附加到变量 activeView。然后调用 registerForContextMenu(activeView)。看起来一切正常,创建了上下文菜单,可
我是一名优秀的程序员,十分优秀!