Ferchi
Ferchi

Reputation: 100

Title on other Activities

I need that the sentence in the mainActivity "datos tarjeta credito" appears also in the top of the second activity. The xml layouts are the same, I don't understand where can I change this. This is what is now:

enter image description here

I tried to attach the xml layouts, but its not working.

Upvotes: 0

Views: 34

Answers (2)

Shiva Snape
Shiva Snape

Reputation: 544

If you are using Activity with Actionbar enabled theme, then you can use below code to change the title of actionbar in all activity programatically.

ActionBar actionBar = getSupportActionBar();
 if (actionBar != null) {
      actionBar.setTitle("Your Title here");
   }

Or you can set the title in manifest itself by:

 <activity
     android:name="your activity name"
     android:label="Your Title Here"/>

Upvotes: 2

Luciano Ferruzzi
Luciano Ferruzzi

Reputation: 1102

In your Activity theme put that:

(I used Theme.AppCompat.Light.DarkActionBar as an example, but anyone should do)

<style name="yourTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowActionBar">true</item>
    <item name="windowNoTitle">true</item>
</style>


<application
    ...
    android:theme="@style/yourTheme"> <!-- apply to all activities ->
    <activity
        android:name=".MainActivity"
        android:theme="@style/yourTheme"> <!-- apply to one activity ->
    </activity>
</application>

Upvotes: 1

Related Questions