我已经使用此处找到的代码和教程实现了 QuickAction 菜单。
我有一个 ListView,我用 SQLite DB 中的记录填充它,当单击记录时,会显示 QuickAction 菜单。What I don't know how to do is take action on the selected record using the QuickAction items (eg update the selected record in the DB when a QuickAction item is selected).
这是我的 QuickAction onclick 监听器:
quickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener()
{
@Override
public void onItemClick(QuickAction source, int pos, int actionId)
{
ActionItem actionItem = quickAction.getActionItem(pos);
if (actionId == VIEW)
{
[view the record]
}
else if (actionId == UPDATE)
{
[update a value in the db]
}
else
{
[do something else to the record]
}
}
});