0

I need to change the action bar based on some changes done on strings.xml file.

In strings.xml

<string  name="app_url">http://example.com</string>

If i hard code to new url then ActionBar should be different.

<string  name="app_url">http://temparary.com</string>

Is there any way to change action bar style in oncreate method of my class.

Archana
  • 597
  • 4
  • 18

1 Answers1

0

Try this

First in onCreate get string app_url

String str = getString(R.string.app_url);
ActionBar actionbar = getActionBar();

if(str.equalsIgnoreCase("link1")) {

    //style your actionbar according to link1
} else {
    //style your actionbar according to link2
}

EDIT

To Add sprite on Actionbar you can create a 9 patch image and set that image as a BackgroundDrawable of your ActionBar

like

Drawable res = getResources().getDrawable(R.drawable.your_image);
getActionBar().setBackgroundDrawable(res);
Bhargav Thanki
  • 4,924
  • 2
  • 37
  • 43