I was trying to implement OnTouch Event in my application, where user
could touch (move fingers)  anywhere in the screen. I thought the best
way to do that would be, to set OnTouchListener on topmost layout. But
it appears, layouts does not receive all the motion events. Here is a
sample code -

main.xml
------------

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:id="@+id/topLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
        android:id="@+id/txtHello"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Hello!"
    />
</LinearLayout>


public class Hello extends Activity {


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        View topLayout = this.findViewById(R.id.topLayout);
        HelloOnTouchListener l = new HelloOnTouchListener();
        topLayout.setOnTouchListener(l);
    }

    class HelloOnTouchListener implements OnTouchListener{

                @Override
                public boolean onTouch(View arg0, MotionEvent arg1) {
                        // TODO Auto-generated method stub

                        Log.i(tag, arg0 + " " + arg1.getAction());
                        return false;
                }
    }

    private static final String tag = Hello.class.getName();
}


When I touch it prints the ACTION_DOWN MotionEvent, but nothing else.
There is no ACTION_MOVE or ACTION_UP. Am I missing any thing?

I'll really appreciate you help.

Thanks,
Rishi
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to