I am aware that there are two methods to setting a title in an Android Activity
.
Assuming I already have the following code...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_activity);
...
Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(toolbar);
...I can use either this...
getSupportActionBar().setTitle("My title");
...or this...
toolbar.setTitle("My title");
...to set my title.
My question is, which is the better practice?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…