I am developing an application and would like to have the user
navigate the app using gestures. I tried using the GestureDetector but
some of the gestures are not detected. I am trying to allow them to go
backwrds and forward by doing a left-to-right and right-to-left
gestures. I tried to detect the onFling and onScroll and I got
nothing, any help would be greatly appreciated.

Here is my code, just in case:

public class MyActivity extends Activity implements OnTouchListener,
OnGestureListener{

        GestureDetector mGestureDetector;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                // TODO Auto-generated method stub
                super.onCreate(savedInstanceState);

                mGestureDetector = new GestureDetector(this);
                mGestureDetector.setIsLongpressEnabled(false);
                setContentView(R.layout.article);

                TextView tv = (TextView)findViewById(R.id.page);
                tv.setOnTouchListener(this);
                tv.setText(R.string.article_text);
        }

        public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                return mGestureDetector.onTouchEvent(event);
        }

        public boolean onDown(MotionEvent e) {
                // TODO Auto-generated method stub
                return false;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX,
                        float velocityY) {
                // TODO Auto-generated method stub
                Toast.makeText(this, "Fling", Toast.LENGTH_SHORT).show();
                return false;
        }

        public void onLongPress(MotionEvent e) {
                // TODO Auto-generated method stub
                //Toast.makeText(this, "Long Press", Toast.LENGTH_SHORT).show();
        }

        public boolean onScroll(MotionEvent e1, MotionEvent e2, float
distanceX,
                        float distanceY) {
                // TODO Auto-generated method stub
                 Toast.makeText(this, "Scroll", Toast.LENGTH_SHORT).show();
                return false;
        }

        public void onShowPress(MotionEvent e) {
                // TODO Auto-generated method stub

        }

        public boolean onSingleTapUp(MotionEvent arg0) {
                // TODO Auto-generated method stub
                return false;
        }

}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to