Android 上下文菜单的列表视图行中的信息

发布于 2024-08-23 15:04:28 字数 340 浏览 1 评论 0原文

我创建了一个 Android 应用程序,其中有一个 Activity,其中有一个 ListView,其中列出了所有当前用户(每一行只是他们的个人资料的图像以及一些带有当前状态和用户名的文本)。

我添加了一个上下文菜单,这样长按会弹出几个选项,例如“查看个人资料”、“发送消息”等。

在 ContextMenu 处理程序中,如何提取信息以了解哪个用户单击了上下文菜单(例如,如果我选择 userX,然后选择“查看配置文件”,那么它将需要能够检索 userX 对象并加载配置文件)

由于该行当前仅具有描述性文本集,我是否还需要嵌入一些其他隐藏的用户ID什么的?关于如何设置/检索此类数据有什么想法吗?

谢谢

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.

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)

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?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文