Home  >  Q&A  >  body text

java - 多个活动使用同一个Drawerlayout(如何封装基类?)

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

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

  1. 如何封装基类

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

大家讲道理大家讲道理2743 days ago541

reply all(3)I'll reply

  • 高洛峰

    高洛峰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

    reply
    0
  • PHP中文网

    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.

    reply
    0
  • 大家讲道理

    大家讲道理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

    reply
    0
  • Cancelreply