Android 列表活动点击次数

发布于 2024-10-06 21:58:06 字数 131 浏览 0 评论 0原文

我有一个 ListActivity 作为我的主要活动。我希望能够对列表中的单个项目执行一些操作,即

长按以调出该项目的上下文菜单 从左向右滑动可从右侧滑动新屏幕以编辑列表项。

有谁可以向我展示执行此操作的任何代码吗?

I have a ListActivity as my main activity. I want to be able to do a few things on a single item in the list i.e.

Longpress to bring up a contextmenu for that item
Swipe left to right to slide a new screen from the right to edit the list item.

Does anyone have any code they can show me that does this?

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

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

发布评论

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

评论(2

爱*していゐ 2024-10-13 21:58:06

长按可调出该项目的上下文菜单

请参阅此处了解如何使用上下文菜单。 这是一个示例项目,演示了它们的用法。

从左向右滑动可从右侧滑动新屏幕以编辑列表项。

请参阅此处了解如何使用手势库。 这是一个 ViewSwiper,它向 ViewFlipper< 添加手势/代码>。 这里是一个拖放ListView的实现,基于一些从 Android 本身中剔除的难以理解的代码。将所有这些融合在一起,您也许能够实现您所寻求的。然而,这将相当困难,并且可能不会产生非常有用的用户界面。我强烈鼓励您仅使用列表项点击作为指示编辑项目的方式,而不是手势。

Longpress to bring up a contextmenu for that item

See here for how to use context menus. Here is a sample project that demonstrates their use.

Swipe left to right to slide a new screen from the right to edit the list item.

See here for how to use gesture libraries. Here is a ViewSwiper that adds gestures to a ViewFlipper. Here is an implementation of a drag-and-drop ListView, based on some poorly-understood code culled from Android itself. Blending all of that together, you may be able to implement what you seek. However, this will be rather difficult, and may not result in a user interface that is very usable. I strongly encourage you to simply have list item clicks be the way to indicate to edit an item, not a gesture.

青衫儰鉨ミ守葔 2024-10-13 21:58:06

我认为您可以使用 2 Child ViewFlipper 作为您的列表项。
一个孩子用于正常显示(可能是 TextView),另一个孩子用于 EditText。
如果它像你说的那样工作,不要忘记在 ViewFlipper 上设置 gesterListener,在 OnFling 方法中执行 showNext 或 showPrevious 。

I think You can use a 2 Child ViewFlipper as your Listitem.
one child for a normal dispaly(a TextView maybe), another a EditText.
and in case it work as you said, don't forget to set gesterListener on your ViewFlipper,do showNext or showPrevious in your OnFling method.

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