轻扫与标签主机主机、标签

2023-09-04 23:50:09 作者:恰好心动i

我有一个TabHost控制(而不是在动作条),和我想要的标签,当用户扫描范围内的每个选项卡上(像WhatsApp的表情选项卡)更改。 我怎样才能做到这一点?

I have a TabHost control (not in actionbar), and I want to make the tabs to change when the user swipes the context on each tab (something like whatsapp emoticon tabs). How can I do this?

修改 手感也很重要。我想,该环境应该有滚动动画(不管用户刷卡或者如果标签被点击)。

EDIT The feel is also important. I want that the contexts should have scroll animations (No matter if the user swipe or if the tab is clicked).

推荐答案

通过这个链接     的http://thepseudo$c$cr.word$p$pss.com/2011/10/13/android-tabs-viewpager-swipe-able-tabs-ftw/

Go through this link http://thepseudocoder.wordpress.com/2011/10/13/android-tabs-viewpager-swipe-able-tabs-ftw/

您可以使用手势检测。

GestureDetector

GestureDetector

检测用附带的MotionEvents各种手势和事件。该GestureDetector.OnGestureListener回调会通知用户发生了特定的运动事件时。这个类只能用于通过触摸(不要使用轨迹球事件)报告MotionEvents。要使用这个类:

Detects various gestures and events using the supplied MotionEvents. The GestureDetector.OnGestureListener callback will notify users when a particular motion event has occurred. This class should only be used with MotionEvents reported via touch (don't use for trackball events). To use this class:

1为您的视图在nTouchEvent(MotionEvent)创建GestureDetector的实例方法保证你叫

1 Create an instance of the GestureDetector for your View In the nTouchEvent(MotionEvent) method ensure you call

2的onTouchEvent(MotionEvent)。该事件发生时在回调中定义的方法将被执行

2 onTouchEvent(MotionEvent). The methods defined in your callback will be executed when the events occur

本页面展示了如何使用GestureDetector承认轻扫手势:

This page shows how to recognize a swipe-gesture using the GestureDetector:

的http://smartandroidians.blogspot.in/2010/04/swipe-action-and-viewflipper-in-android.html

 
精彩推荐
图片推荐