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?

Kristiyan Varbanov
  • 2,439
  • 2
  • 17
  • 37
mila
  • 13
  • 1
  • 4

7 Answers7

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");}
byDavid360
  • 68
  • 9
0

Simply using this line of code :

getSupportActionBar().setTitle("Form");
Mann
  • 560
  • 3
  • 13
0

you just need to do

getActionBar().setTitle("Test");
Kaushik
  • 6,150
  • 5
  • 39
  • 54
Shekhar
  • 254
  • 2
  • 10
0

In you second activity in OnCreate method add this line

getSupportActionBar().setTitle("Form");
Kristiyan Varbanov
  • 2,439
  • 2
  • 17
  • 37
0

Try this toolbar.setTitle("title");

Shahal
  • 1,008
  • 1
  • 11
  • 29
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");
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
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>
János Farkas
  • 453
  • 5
  • 14