如題,多個(gè)活動(dòng)使用同一個(gè)drawerlayout,想問怎么封裝基類?
因?yàn)槲蚁隿lick事件效果都一樣,感覺沒必要再寫一遍,想問一下
如何封裝基類
基類子類布局文件怎么寫?
光陰似箭催人老,日月如移越少年。
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
,所有你可以自定義一個(gè)類繼承drawerlayout
,在其中可以就可以做許多事情,例如你的需求:進(jìn)行統(tǒng)一的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