Android ViewSwitcher with OnGestureListener

PrDoHung · 35K views · 2011 · 0:34

Open on YouTube

Software (other)Web developmentdemodated

Why Stack Overflow recommends it

Stack Overflow users link it when answering how to swipe or fling between views or images in Android, as a working ViewSwitcher and gesture example with source.

Recommended by 2 people across 3 different months, 2011 to 2013.

What it is

A 34-second Android demo from 2011 showing a ViewSwitcher driven by GestureDetector.OnGestureListener, using touch and fling gestures to swipe between views. The description links the official Android docs and a downloadable source code project.

What people said

Strong rec MrZander · 2011-12 · Stack Overflow · on “Android - horizontal scrolling of multiple viewable items”

I can think of two ways to possibly implement this. By a ViewSwitcher [LINK] . Here is an excellent [this video] showing how it works with an onGestureListener [LINK] . However, I am not sure if this will work with multiple views like your picture shows. As an alternative, you could use a HorizontalScrollView [LINK] . However, this often causes issues if you have one ScrollView inside of a another, but it may be worth a shot! Let me know how it goes, Good luck!

Recommends K_Anas · 2012-05 · Stack Overflow · on “How to invoke multiple events on same button click in android”

see this project [this video] on youTube basically it uses the same approche as you want except it switches only between images, you can amelirate it by using the View switcher for a views that contains imageview and text view, the source is attached too and the project switches between images using touch gesture too:

Recommends K_Anas · 2012-06 · Stack Overflow · on “View Flipper Android”

ViewSwitcher can handle this for you, here [LINK] a view switcher in action You can also find here an example [this video] with source code attached to it

Cites inazaruk · 2011-07 · Stack Overflow · on “Android: Show array of Images in Image View”

You can use ViewFilpper [LINK] or ViewSwitcher [LINK] or ImageSwitcher [LINK] for your purposes. All these classes extend ViewAnimator , so they have very similar behavior and functionality, and only add a few useful function on top of what ViewAnimator has. Demo: [this video]

Cites Gürcan Kavakçı · 2013-01 · Stack Overflow · on “How to show single list item on all screen at a time?”

I found simple solution for my question. ViewSwitcher with OnGestureListener solves my problem. [this video] References: ViewFlipper: [LINK] ViewSwitcher: [LINK] GestureDetector.OnGestureListener: [LINK] Source Code: [LINK] My activity doesn't have all code, so maybe it may not work. But logic is here. -------My solution-------- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" [LINK] " android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ViewSwitcher android:id="@+id/viewSwitcher" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" > <RelativeLayout android:layout_width="fill_pare