A relatively simple method can be to extract the layout in the drawer into a Fragment, expose the corresponding interface and data, and dynamically add it to a new activity each time
First of all, you need to be clear about what you want to encapsulate? Yes drawerlayout,所有你可以自定义一个类继承drawerlayout,在其中可以就可以做许多事情,例如你的需求:进行统一的click操作。使用的话可以直接在任何类(自然包括基类如果必要的话)的布局中使用自定义的drawerlayout.
If this is the case, you can put the click event or something in the parent class. The parent class is an abstract class. The DrawerLayout method of filling the layout calls the abstract method written by the parent class and is implemented by the subclass itself
A relatively simple method can be to extract the layout in the drawer into a Fragment, expose the corresponding interface and data, and dynamically add it to a new activity each time
First of all, you need to be clear about what you want to encapsulate? Yes
drawerlayout
,所有你可以自定义一个类继承drawerlayout
,在其中可以就可以做许多事情,例如你的需求:进行统一的click
操作。使用的话可以直接在任何类(自然包括基类如果必要的话)
的布局中使用自定义的drawerlayout
.If this is the case, you can put the click event or something in the parent class. The parent class is an abstract class. The DrawerLayout method of filling the layout calls the abstract method written by the parent class and is implemented by the subclass itself