2

In my code, I use a predetermined XML layout to generate the Views in my Activity. I don't create them programmatically, therefore I can't find a way to override the onInterceptTouchEvent method! Is there a way to do this?

Wakka02
  • 1,491
  • 4
  • 28
  • 44

1 Answers1

3

Extend the class you are interested in:

package com.myapp;

public class MyLayout extends RelativeLayout { 

    // Don't forget to include all the super constructors...

    public void onInterceptTouchEvent(...){}

}

Then, you can use that class in xml like this:

<com.myapp.MyLayout
    android:id="@+id/my_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- acts just like a RelativeLayout, except for your custom code -->

</com.myapp.MyLayout>
Jay Bobzin
  • 1,020
  • 8
  • 14