Using onInterceptTouchEvent

后端 未结 1 1542
说谎
说谎 2021-01-15 07:43

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 onInt

相关标签:
1条回答
  • 2021-01-15 08:44

    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>
    
    0 讨论(0)
提交回复
热议问题