Common Clickable Header for All Activities in Android

后端 未结 2 2071
面向向阳花
面向向阳花 2020-12-09 13:13

I have an application with a common Header in all layouts. I want that whenever the user clicks at the the ImageView with id btn_home, the app will go back to a

2条回答
  •  孤街浪徒
    2020-12-09 13:35

    Extend the Activity class and build a MyActivity class for example. In this MyActivity class you could include the code for the onClick.

    Now create a layout that just holds your header. Include that layout in your activity layouts.

    Extend all your activities from MyActivity - that's it.

    If you need the same behaviour in ListActivities create a MyListActivity as well.

提交回复
热议问题