java - 多个活动使用同一个Drawerlayout(如何封装基类?)
大家讲道理
大家讲道理 2017-04-18 10:54:49
0
3
580

如题,多个活动使用同一个drawerlayout,想问怎么封装基类?

因为我想click事件效果都一样,感觉没必要再写一遍,想问一下

  1. 如何封装基类

  2. 基类子类布局文件怎么写?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
小葫芦

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

Ty80

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template