Android - ListView 向左/向右滑动,就像三星联系人 ListView 一样
我正在开发一个应用程序,我需要一个类似于我的三星 Galaxy S 的联系人 ListView 的 ListView:
当我向右滑动手指时,我可以向该联系人发送消息。
当我向右滑动手指时,我可以呼叫我的联系人。
我有我的 ListView,只需要执行此操作的功能...
提前致谢。
PD: 我搜索了很多,但没有找到任何东西。最相似的是: 列表视图上的 Android 轻微向左/向右滑动操作的资源< /a>
I am developing an application, and I need a ListView like conctact ListView of my Samsung Galaxy S:
When I slide my finger to the right I can send message to this contact.
When I slide my finger to the right I can call to my contact.
I have my ListView and only need the function for do it...
Thanks in advance.
PD:
I searched a lot and have not found anything. The most similar:
Resource for Android Slight Left/Right Slide action on listview
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在另一篇文章中,有一个指向此 Google 代码的链接:https://gist.github.com/2980593
来自此 Google+ 帖子:https://plus.google.com/u/ 0/113735310430199015092/posts/Fgo1p5uWZLu 。
这是滑动关闭功能。
您可以从中提供您自己的“滑动操作”代码。这是我的版本,我可以个性化左右动作,并且可以触发“关闭”动画(这只是对 Roman Nuric 代码的修改)。
您必须在项目中包含此类:
从那里,您可以使用 ListView 将以下代码添加到 Activity 中的 onCreate 中:
编辑:
要在滑动时添加颜色修改,您的代码必须位于靠近
mDownView.setAlpha
的case MotionEvent.ACTION_MOVE
中。From another post, there was a link to this Google Code : https://gist.github.com/2980593
Which come from this Google+ post : https://plus.google.com/u/0/113735310430199015092/posts/Fgo1p5uWZLu .
This is a Swipe-To-Dismiss functionality.
From this you can provide your own Swipe-To-Action code. So here is my version, were I can personalize the left and right action and you can triggered the Dismiss animation (this is just a modification of Roman Nuric's code).
You have to include this class in your project :
From there, you can add the following code to your onCreate in the Activity with the ListView :
Edit:
To add a color modification while swiping, your code must be in the
case MotionEvent.ACTION_MOVE
close to themDownView.setAlpha
.您可能在这里要做的是创建一个新视图,特别是列表视图(称为 ListViewFlinger 或其他名称)。然后在此视图中,重写其 onTouchEvent 方法并在其中放置一些代码来确定滑动手势。一旦你有了滑动手势,就触发一个 onSlideComplete 事件(你必须让该侦听器),瞧,你就是一个带有滑动激活内容的 ListView。
What you might what to do here is create a new view especially for the list view (call it ListViewFlinger or something). Then in this view, override its onTouchEvent method and place some code in there to determine a slide gesture. Once you have the slide gesture, fire a onSlideComplete event (you'll have to make that listener) an voialla, you a ListView with slide activated content.
如果您想在滑动时执行操作:
这是一个很棒的库,允许使用底层的布局或颜色,并在完成滑动/滑动手势时执行所需的操作。您可以配置它来显示/更改布局。
~ 我没有使用过三星联系人应用程序,但听起来这就是您想要的
如果您想滑动到显示可操作按钮:
从某种意义上来说,它更像是 Swipe-able iOS 中的表格视图。
< /a>
< /a>
< /a>
If you want to Perform an action On Swiping:
It's an awesome library that allows Swipe in both directions with an underlying
Layout
orColor
, and performs a desired action when the swipe/slide gesture is done. You can configure it to reveal/change the layout.~ I haven't used the Samsung Contacts app, but sounds like this is what you want
If you want to swipe to Reveal actionable buttons:
In a sense, it is more like the Swipe-able TableViews in iOS.