轻扫与标签主机 [英] Swipe with tab host

查看:192
本文介绍了轻扫与标签主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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

这篇关于轻扫与标签主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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