extending navigation drawer activity to other activities

前端 未结 6 1090

I\'m trying to create a navigation drawer activity so I can extend that activity and use the menu in all activities by following the answer given in this question Link but m

6条回答
  •  隐瞒了意图╮
    2020-12-10 06:22

    On the parent classBaseActivity:

    • declare a protected abstract int getLayoutId();

    • onCreate() I added the line

      setContentView(getLayoutId());
      

    Now implement it on your subclass MainActivity something like:

     protected int getLayoutId() {
        return R.layout.activity_profile;
    }
    

    Please tell me if you know a better solution.

提交回复
热议问题