I have an activity defined as:

public class MyDemo extends Activity
{
        @Override
        public void onCreate( Bundle savedInstanceState )
        {
                super.onCreate( savedInstanceState );
                setContentView( R.layout.main );
        }

        @Override
        public boolean onTouchEvent(MotionEvent me)
        {
                Log.i("MyDemo motion", "" + me.getAction());
                return false;
        }
}

With this custom view in main.xml

<?xml version="1.0" encoding="utf-8"?>
  <com.test.MyCustomView
    xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"  />

MyCustomView.java contains

public class MyCustomView
        extends FrameLayout
        implements OnGestureListener
{
        public MyTest( Context context, AttributeSet attrs )
        {
                super( context, attrs );
                LayoutInflater.from( context ).inflate( R.layout.doofer, this,
true );
        }

        @Override
        public boolean onTouchEvent(MotionEvent me)
        {
                Log.i("MyCustomView motion", "" + me.getAction());
                return false;
        }
}

And finally doofer.xml is

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:id="@+id/dooferFrame"
    android:layout_width="200dip"
    android:layout_height="200dip"
    android:background="#80ff0000" >
    <TextView
        android:id="@+id/doofer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
</FrameLayout>

So... looking at LogCat we can see the motion events that occur.  The
MyDemo Activity logs down, up and move events perfectly as expected.
However, MyCustomView only logs down events!

Why aren't ACTION_UP and ACTION_DOWN Touch Events passed through to
custom views?

I need to handle the touch events in the custom view (not the
activity) because there are several custom views in the activity and
all of them need to respond individually to fling motions.  Detecting
fling events in the activity wont tell me over which view the fling
event happened.  So i would like to handle the touch events in the
custom view (its a better OO practice than handling it in the
Activity).

Any Clue?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to