1

I am new to implement the ListView with section.

I have use this application to implement the section to my list view.

Now I want to add the Titlebar that display the application page title. Then where do I have to make a change? In the xml file or in the Java file?

Please refer the example and let me tell what should I have to change to make Titlebar for my app.

richq
  • 54,082
  • 20
  • 146
  • 143
Shreyash Mahajan
  • 22,842
  • 35
  • 109
  • 188

3 Answers3

2

There are two ways to change title bar for your activity:

  1. Design time (that is, change title in AndroidManifest.xml file).
  2. By coding (that is, you can code to change the activity title).

Example for 1st:

you can Change the Title of each screen (i.e. Activity) by setting their Android:label inside the AndroidManifest.xml file:

<activity android:name=".Hello_World"
                  android:label="This is the Hello World Application">
   </activity>

And yes, to display customized title bar for your activity, go through this answer: How to change the text on the action bar

Community
  • 1
  • 1
Paresh Mayani
  • 125,853
  • 70
  • 238
  • 294
2

Try this...

final Activity activity = this;
activity.setTitle("Settings");

if you disabled the title bar using, this.requestWindowFeature(Window.FEATURE_NO_TITLE); remove it.

(OR)

Try this..

        final Activity activity = this;
        this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.settings);
        activity.setTitle("Settings");
Noby
  • 6,322
  • 9
  • 38
  • 63
1

In your AndroidManifest.xml file you have a section for each activity that looks like this

    <activity
        android:label="Your Activity"
        android:name=".YourActivity" />

where the android:label tag defines what the text in the titlebar is.

skynet
  • 9,828
  • 5
  • 42
  • 52