Common Header in different activities using BaseActivity in android

前端 未结 4 1517
傲寒
傲寒 2020-12-03 05:10

I want write code once and use in different activities. I have created a Base Activity class for that . Also the header of all the layouts in different activiti

4条回答
  •  独厮守ぢ
    2020-12-03 06:02

    In code, your base activity is called ExampleActivity, but in your child class you are extending BaseActivityMenu. Don't know where its coming from.

    Perhaps change:

    public class ABCActivity extends BaseActivityMenu
    

    To this:

    public class ABCActivity extends ExampleActivity
    

    Moreover, I would suggest you to define your base activity (ExampleActivity) as an Abstract class. For example:

    public abstract class ExampleActivity extends Activity
    

    Doing so will not define your base class as concrete and will make it easier to debug in case of problems.

提交回复
热议问题