Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / Android

Change an Android Layout's default header text

5.00/5 (2 votes)
16 May 2014CPOL1 min read 19.1K  
How to quickly and easily change a Layout's header text

I Don't Know What to Call This Guy...

When you create an Activity/Layout pair, the default text defining the Layout (the name of the Activity) will display to the right of the cute little green Android with the transparent belly who seems to have swallowed a di[c]e which has had the dye inside its debossed divits worn away by robot stomach acid (or is that simply an upside-down peace sign?)*:

Image 1

* There must be an official moniker for the glyph of that cute li'l feller, but I obviously don't know what it is.

It could be that the text shown is something that is not human-friendly, such as "DeliveryItemActivity".

...But Changing the Text is as Easy as Pie

If so, and you want it to be something else, perhaps just inserting spaces between the words (such as "Delivery Item Activity"), or even change it to something totally different, here is how you do that:

Open the strings.xml file (beneath [projectName]\app\src\main\res\values) and locate the string value that you want to replace. In the example given, it is:

XML
<string name="title_activity_delivery_item">DeliveryItemActivity</string>

Now change it to:

XML
<string name="title_activity_delivery_item">New Delivery</string>

..and voila! The Layout now bears that new text description to your right/the left of your little green buddy:

Image 2

Of course, the text you use is up to you - you could make it "Zombies: Time of the Season, She's Not There, Tell Her No" if you wanted to.

Image 3

Hopefully, that great and vastly underappreciated band will get back together and release an album entitled "Apocalypse"!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)