0

This one is similar to a question that I asked yesterday. However my concern is different. To summarize I needed to remove the text from the titlebar for one of my activities (the main activity) (1). I did this using setTitle(""); on the onCreate method. However when starting the application the former title remains displayed during 2 secs before changing to the new one.

It is probably because the titlebar is loaded before the activity loads, and I guess I either need to make the titlebar loads at the same time than when the activity loads or do this not in the code but in xml files.

Any idea?

Thanks!

(1): The reason why I want to do this is explained here.

Community
  • 1
  • 1
Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158

4 Answers4

1

You can do it from manifest file for each activity separately. Look here.

Community
  • 1
  • 1
woodshy
  • 4,085
  • 3
  • 22
  • 21
0

If you want to do it programmatically use setTitle(); in onCreate

For example, I have an activity that can be used for two purposes: either to add a new item or to edit an existing one to a database.

if (editThis == null) {
    setTitle(getString(R.string.new_item)); //set activity title to new
        } else {
    setTitle(getString(R.string.edit_item)); // set Editor title to edit

}

In this example editThis is an incoming intent, data or similar that indicates that we want to edit an existing item.

As for the title changing after a few seconds. Do you have a title set for the activity, say in the Manifest? Chances are the app is loading that information first, only then to proceed to the line where you tell it to change that again.

atschpe
  • 121
  • 14
0


Try this

@Override
public void onCreate(Bundle state)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);

You can also try to supply your own title layout

@Override
public void onCreate(Bundle state)
{
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);

l_39217_l
  • 2,090
  • 1
  • 13
  • 15
  • I don't want to remove the titlebar. I want to remove the **text** from the titlebar. I actually have a titlebar -- which is a png. The problem is that I have the label (which is needed to name the application) written on this png, which is ugly. Hence the need to only remove that label from the titlebar. – Amokrane Chentir Jul 05 '11 at 13:56
-1

Go to your values folder, to strings.xml. Here you see app_name string. Edit that one to your desired label.

usealbarazer
  • 707
  • 3
  • 10
  • 27
  • That isn't very robust... the question isn't how to rename the app, but rather how to modify the text for one of the Activities. – Daryl Bennett Dec 08 '14 at 23:50