表格行长按
我有一个表,它是根据存在的数据量(如果有的话)动态构建的。
我希望能够长按表格行上的任意位置,以便能够获得一些用于删除或编辑等的选项。这可能吗?请记住,我需要在动态构建时不设置任何 XML 来完成所有这些操作。
这与我想要实现的目标相关吗?
@override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK)
{
// do your stuff here
return true;
}
return super.onKeyLongPress(keyCode, event);
}
`
任何建议表示赞赏。
I have a table which is built dynamically based on how much data is present, if at all.
I want to be able to long press anywhere on a the table row to be able to get some options to delete or edit etc. Is this possible? Remember I need to do all this without setting any XML as its dynamically built.
Is this relevant to what I want to achieve?
@override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK)
{
// do your stuff here
return true;
}
return super.onKeyLongPress(keyCode, event);
}
`
any advice is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将上下文菜单注册到动态创建的 Table Row 。
调用
registerForContextMenu(tableRow)
并重写onCreateContextMenu(ContextMenu, View, ContextMenu.ContextMenuInfo)。
了解上下文菜单
Register context menu to dynamically created Table Row .
call
registerForContextMenu(tableRow)
and overrideonCreateContextMenu(ContextMenu, View, ContextMenu.ContextMenuInfo).
Read about Context Menu
这是我从 Mark Murphy 的书中改编的一些示例代码。我的列表基于数据库。
Here is some example code that I adapted from Mark Murphy's books. My list is based on a database.