I figured out how to do it for any1 interested
@Override
public boolean dispatchTouchEvent(MotionEvent ev){
super.dispatchTouchEvent(ev);
return gestureScanner.onTouchEvent(ev);
}
On Jun 14, 2:43 pm, SurtaX <[email protected]> wrote:
> bump
>
> On Jun 13, 8:18 pm, SurtaX <[email protected]> wrote:
>
>
>
> > I'm making sort of a book app. I have the text displayed as a textview
> > in a scrollview:
>
> > XML:
> > <ScrollView
> > android:id="@+id/chatview"
> > android:orientation="vertical"
> > android:layout_width="fill_parent"
> > android:layout_height="fill_parent">
> > <TextView
> > android:id="@+id/webview"
> > android:layout_width="wrap_content"
> > android:layout_height="fill_parent"
> > android:layout_weight="1"
> > android:textSize = "16sp" />
> > </ScrollView>
>
> > I then have
>
> > Java:
> > private GestureDetector gestureScanner;
> > public void onCreate(Bundle savedInstanceState) {
> > super.onCreate(savedInstanceState);
>
> > gestureScanner = new GestureDetector(this);
> > }
>
> > And implemented the required following to catch a left fling or right
> > fling. And
>
> > Java:
> > �...@override
> > public boolean onTouchEvent(MotionEvent me)
> > {
> > return gestureScanner.onTouchEvent(me);
> > }
>
> > public boolean onDown(MotionEvent e)
> > {
> > return true;
> > }
>
> > public boolean onFling(MotionEvent e1, MotionEvent e2, float
> > velocityX, float velocityY)
> > {
> > if(velocityX >= 1500){
> > nextChapter();
> > }
> > if(velocityX <= -1500){
> > previousChapter();
> > }
> > return true;
> > }
>
> > public void onLongPress(MotionEvent e)
> > {
> > }
>
> > public boolean onScroll(MotionEvent e1, MotionEvent e2, float
> > distanceX, float distanceY)
> > {
> > return true;
> > }
>
> > public void onShowPress(MotionEvent e)
> > {
> > }
>
> > public boolean onSingleTapUp(MotionEvent e)
> > {
> > return true;
> > }
>
> > This works fine if the text inside the textview is small (ie. there is
> > no scroll bar as it all fits within the view). But as soon as the text
> > requires scrolling, the gesture is no longer picked up by the
> > detector. onFling is never called.
>
> > I have read that it is because scrollview handles its own gestueres?
> > If so what is the easiest way to maintain the ability to scroll up and
> > down the text, and also be able to detect flinging left or right and
> > invoking nextChapter() and previousChapter() respectively?
>
> > THanks alot for your time.
>
> > Cheers,
> > SurtaX
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---