如题,多个活动使用同一个drawerlayout,想问怎么封装基类?
因为我想click事件效果都一样,感觉没必要再写一遍,想问一下
如何封装基类
基类子类布局文件怎么写?
高洛峰2017-04-18 10:56:49
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
PHP中文网2017-04-18 10:56:49
First of all, you need to be clear about what you want to encapsulate? Yes drawerlayout
,所有你可以自定义一个类继承drawerlayout
,在其中可以就可以做许多事情,例如你的需求:进行统一的click
操作。使用的话可以直接在任何类(自然包括基类如果必要的话)
的布局中使用自定义的drawerlayout
.
大家讲道理2017-04-18 10:56:49
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