i have implemented OnTouchListener for my view which uses the
gestureDetecter.

here i am posting my code..

########### Code starts here #################

public WebText(Context context) {
                super(context);
                initilizeAll(context);
        }

        public void initilizeAll(Context context) {
                this.context = context;
                viewGestureDetector = new GestureDetector(new 
MyGestureListener());
                swip = (SwipInterfase) context;
                this.setOnTouchListener(this);
        }

        @Override
        public boolean onTouch(View v, MotionEvent event) {

                if (viewGestureDetector.onTouchEvent(event)) {
                        return true;
                }
                return false;

        }

        class MyGestureListener extends SimpleOnGestureListener {

                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                        return swip.onSingleTap(e);
                }

                @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;
                                }

                                // right to left swipe
                                if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
                                                && Math.abs(velocityX) > 
SWIPE_THRESHOLD_VELOCITY) {
                                        Toast.makeText(context, "Left Swipe", 
Toast.LENGTH_SHORT)
                                                        .show();

                                        swip.leftSwip();

                                } else if (e2.getX() - e1.getX() > 
SWIPE_MIN_DISTANCE
                                                && Math.abs(velocityX) > 
SWIPE_THRESHOLD_VELOCITY) {
                                        Toast.makeText(context, "Right Swipe", 
Toast.LENGTH_SHORT)
                                                        .show();
                                        swip.rightSwip();
                                }
                        } catch (Exception e) {
                                // nothing
                        }
                        return true;
                }

        }

########### Code ends here #################

where as it works properly on android 2.3 and lower versions..
when i tried to install in HonyComb(xoom skin emulator) it throwing
NullPointerException exception..(see at below..)

please any help....?
Thanks in Advance...



03-08 14:34:10.768: ERROR/AndroidRuntime(779): FATAL EXCEPTION: main
03-08 14:34:10.768: ERROR/AndroidRuntime(779):
java.lang.NullPointerException
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.GestureDetector.onTouchEvent(GestureDetector.java:576)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
com.jinibook.android.view.WebText.onTouch(WebText.java:56)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.View.dispatchTouchEvent(View.java:4458)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:
1469)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1237)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:
1475)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1250)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:
1475)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1250)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:
1475)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1250)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:
1475)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1250)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:
1475)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1250)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchTouchEvent(PhoneWindow.java:1706)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:
1276)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.app.Activity.dispatchTouchEvent(Activity.java:2258)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1686)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2235)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1927)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.os.Handler.dispatchMessage(Handler.java:99)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.os.Looper.loop(Looper.java:126)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
android.app.ActivityThread.main(ActivityThread.java:3900)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
java.lang.reflect.Method.invokeNative(Native Method)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
java.lang.reflect.Method.invoke(Method.java:491)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-08 14:34:10.768: ERROR/AndroidRuntime(779):     at
dalvik.system.NativeStart.main(Native Method)

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