1

I'm doing a project in Android Studio using empty activities but in both of them the title still being the same, like in the image:

enter image description here

How can I change the title of the second activity to 'Form' instead of 'Agenda' as well?

2

7 Answers 7

2

It is very easy. In every .class you want a different title in your actionbar, you only have yo setTitle. Like here:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("Your custom title");} 
Sign up to request clarification or add additional context in comments.

Comments

0

Simply using this line of code :

getSupportActionBar().setTitle("Form"); 

Comments

0

In you second activity in OnCreate method add this line

getSupportActionBar().setTitle("Form"); 

Comments

0

Try this toolbar.setTitle("title");

1 Comment

op didn't use toolbar as actionbar
0

Just do this.

Add this in your Form activity class onCreate method.

ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setTitle("Form"); 

Comments

0

you just need to do

getActionBar().setTitle("Test"); 

Comments

0

call

setTitle("title") 

onCreate, or u can set label in AdnroidManifest.xml file to activity:

<activity android:name=".ActivityName" android:label="custom label string" android:theme="theme..." > <intent-filter> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.