从列表视图行信息为Android上下文菜单 [英] Information from listview row for Android context menu

查看:141
本文介绍了从列表视图行信息为Android上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了针对Android的应用程序,有,有一个ListView列出所有当前用户的活动(每行是他们的个人资料只是以及与它们的当前状态和用户名一些文本的图像)。

I have created an application for Android that has an activity that has a ListView which lists all current users (each row is just an image of their profile along with some text with their current status and username).

我添加了一个文本菜单,这样长的点击带来了几个选项,如查看资料,发送消息,等等。

I have added a contextmenu, so that a long-click brings up several options such as "view profile", "send message", etc.

在文本菜单处理程序中,我怎样才能提取信息,知道哪些用户的上下文菜单已经被点击了(例如,如果我选择userX,然后选择查看资料那就需要能够检索userX对象并加载配置文件)

In the ContextMenu handler, how can I extract information to know which user the context menu has been clicked for (for example, if i select userX and then selected "view profile" then it would need to be able to retrieve the userX object and load the profile)

由于该行目前只具有说明性的文字集,将我还需要嵌入一些其他隐藏的用户ID或东西吗?我如何可以设置任何想法/检索这些数据?

As the row currently only has descriptive text set, would i need to also embed some other hidden user ID or something? any thoughts on how i could set/retrieve such data?

感谢

推荐答案

从这里开始:

<一个href="http://stackoverflow.com/questions/2321332/detecting-which-selected-item-in-a-listview-spawned-the-contextmenu-android">http://stackoverflow.com/questions/2321332/detecting-which-selected-item-in-a-listview-spawned-the-contextmenu-android

<一个href="http://stackoverflow.com/questions/433761/how-do-you-implement-context-menu-in-a-listactivity-on-android">http://stackoverflow.com/questions/433761/how-do-you-implement-context-menu-in-a-listactivity-on-android

此外,这里是一个示例项目演示得到一个数据库行的_ID支持删除上下文菜单项。

Also, here is a sample project that demonstrates getting the _ID of a database row in support of a "Delete" context menu item.

这篇关于从列表视图行信息为Android上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆