Android PagerTabStrip and PagerTitleStrip with ViewPager

Note: This post is sort of a continuation of my previous post on ViewPager and its related pager adapters with tabs.

When working with ViewPager we most likely include action bar tabs and integrate them with their corresponding screens in the ViewPager. Action bar tabs works great but just incase if you prefer scrollable tabs and want to use them over action bar tabs then there are two ways to achieve that:

Continue reading “Android PagerTabStrip and PagerTitleStrip with ViewPager”

Android Swipe (Touch Gesture) Views Using ViewPager, FragmentPagerAdapter and FragmentStatePagerAdapter With Action Bar Tabs

Swipe Views are an efficient way to allow the user to laterally navigate among related data items spread across multiple panes using a simple touch gesture (swipes/flings), making access to data faster and much more enjoyable. Think of the android home screen where you can swipe across multiple sibling screens or the facebook or twitter app with multiple screens (and their respective tabs) where you can just swipe to navigate through them. The entire experience is super interactive and fun. They’re basically equivalent to slideshows/carousels which has sections with/without tabs (or similar controls to navigate) in the web development arena.

Continue reading “Android Swipe (Touch Gesture) Views Using ViewPager, FragmentPagerAdapter and FragmentStatePagerAdapter With Action Bar Tabs”

Android ViewFlipper and ViewSwitcher with GestureDetector Swipes/Flings

While developing an Android application, most of us will encounter the need to integrate a section in our app where the user can switch between Views. So it should show one view which can be an ImageView or a collection inside LinearLayout, RelativeLayout, etc. at a time that can be swiped/flinged to move to the next or previous item. Think of a slideshow of images or a step-based process like e-commerce checkouts. Basically whenever you want to swipe through a set of related sections but show only one at a time then you can leverage ViewFlipper or ViewSwitcher class widgets that Android provides us. The detection of gestures can be achieved with major use of the MotionEvent class but we’ll make use of GestureDetector for this article.

Continue reading “Android ViewFlipper and ViewSwitcher with GestureDetector Swipes/Flings”

Quick Tip: Android ViewFlipper Jump/Move/Switch To a Certain Child View

At times you might want to jump the user to a specific View inside a ViewFlipper on the click of some other View or some such scenario. So let’s say we have a ViewFlipper in our layout resource like this:

Continue reading “Quick Tip: Android ViewFlipper Jump/Move/Switch To a Certain Child View”

Using onTouchEvent() and View.OnTouchListener Interface with MotionEvent to Detect Common Gestures Like Tap and Swipes on Android

Touch gestures like tapping, swiping vertically/horizontally, panning, etc. occurs when a user places one or more fingers on the screen and by the time the last finger looses contact, the entire pattern of finger movements is interpreted as a particular gesture by your android application. First all the relevant data of touch events are gathered and then they’re interpreted to see which gestures they match and the pertaining actions are executed as specified in the code.

Continue reading “Using onTouchEvent() and View.OnTouchListener Interface with MotionEvent to Detect Common Gestures Like Tap and Swipes on Android”

Detecting Common Gestures on Android Using GestureDetector

Gestures are those subtle motions to trigger interactions between the touch screen and the user. It lasts for the time between the first touch on the screen to the point when the last finger leaves the surface. We’re all familiar with it as it’s the most common way to communicate with apps on our mobiles, tablets, etc. these days. Some examples are scrolling in an app by swiping vertically/horizontally, pinch to zoom, long press to select and so on.

Continue reading “Detecting Common Gestures on Android Using GestureDetector”