How to change the text on the action bar

前端 未结 18 978
春和景丽
春和景丽 2020-11-22 12:30

Currently it just displays the name of the application and I want it to display something custom and be different for each screen in my app.

For example: my home scr

18条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 13:32

    You can define the label for each activity in your manifest file.

    A normal definition of a activity looks like this:

    
    

    Where title text should be replaced by the id of a string resource for this activity.

    You can also set the title text from code if you want to set it dynamically.

    setTitle(address.getCity());
    

    with this line the title is set to the city of a specific adress in the oncreate method of my activity.

提交回复
热议问题