Sunday, 30 September 2018

How can you change an activity title in Android?

Sometimes when we create an activity in Android we don't put appropriate title of activity or may be later on we want to change the activity title. So how can we change it? Let see -

There are two ways to do this.

1. Using Java code
2. Change in XML file

Using Java code-

 setTitle("Your Title");

put this code in activity Java coding page, like-

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("Your Title");

Another way to do this is to change in AndroidManifest.xml file of your project. See the screen shot to locate AndroidManifest.xml


You can see your activity in this file under <application></application> tag. You just have to change/enter the label of your activity.

android:label="Your Title"
  
See bellow- 

<activity android:name=".Your_Activity"    android:label="Your Title">
</activity>

No comments:

Post a Comment

Change image source dynamically on hyperlink

 Changing image source dynamically using JQuery. Here in this example I have created there hyperlink and stored all images in the same folde...