android - Swipe/Fling tab-changing in conjunction with ScrollView? -


the best find on particular issue (although not use gallery): scrollview , gallery interfering - doesn't give specific answer though. , implementation not use gallery, obviously.

jump down next bold part interesting part

so got fling/swipe/flick/whatever want call work while ago on application. inspiration gathered couple of different places, of them being "basic gesture detection" here on stack overflow ( fling gesture detection on grid layout ), code shogun ( http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/ ) , developing android ( http://developingandroid.blogspot.com/2009/09/implementing-swipe-gesture.html ), not use viewflipper in application. when fling occurs change tab (wrapping around @ ends).

now, of tabs contain scrollviews. these scrollviews respond up/down scrolls in order let view data inside it, no surprise there. issue appear 'scroll' function of these scrollviews overwrite fling gesture. cannot fling inside scrollview (scroll fine), works flawlessly outside them (on same tab, on other views such tablerow or whatever).

i had quick @ http://blog.velir.com/index.php/2010/11/17/android-snapping-horizontal-scroll/ too, provides way implement horizontalscrollview. still handles gestures through class extends simpleongesturelistener (and overwrites onfling), same implementation have (which leads me believe won't help). source code scrollview google: http://google.com/codesearch/p?hl=en#ux1gffpyozk/core/java/android/widget/scrollview.java&d=3

is there way have implementation of swipe , scrollview working effortlessly?

this problem lies, guess. scrollview.java uses method called ontouchevent , documentation ontouchevent activity states:

"called when touch screen event not handled of views under it. useful process touch events happen outside of window bounds, there no view receive it."

so scrollview "override" - do? there no way ensure both checked? ontouchevent not hit when ontouchevent handled scrollview:

@override /** used swipe gestures */ public boolean ontouchevent(motionevent event) {     if (gesturedetector.ontouchevent(event))         return true;     else         return false; } 

more general source code below, it's not vital. gesturedetector inside tabs class associated listener:

    // gestures     gesturedetector = new gesturedetector(new mygesturedetector());     gesturelistener = new view.ontouchlistener() {         @override         public boolean ontouch(view v, motionevent event) {             if (gesturedetector.ontouchevent(event)) {                 return true;             }             return false;         }     }; 

my gesture class nested class of tabs class (which extends tabactivity) - it's same other code find on subject:

/** gesturedetector used swipe between classes */ class mygesturedetector extends simpleongesturelistener {     tabhost tabhost = gettabhost();       @override     public boolean onfling(motionevent e1, motionevent e2, float velocityx, float velocityy) {         try {             if (math.abs(e1.gety() - e2.gety()) > swipe_max_off_path) return false;             if (e1.getx() - e2.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) {                 // tab code                 return true;             } else if (e2.getx() - e1.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) {                 // tab code                 return true;             }         } catch (exception e) {             log.e("mygesturedetector onfling", e.tostring());         }         return false;     } } 

i suggest have @ google i/o 2010 app source code, flingabletabhost implementation appear have solved problem:

http://iosched.googlecode.com/svn/trunk/src/com/google/android/apps/iosched/ui/scheduleactivity.java

i think key in extending tabhost , overriding onintercepttouchevent method.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -