Est-il un moyen de mettre actionbar backgound par image dans android?

J'ai besoin de changer d'arrière-plan de la barre d'action pour une personnalisation de l'image, mais à chaque fois que j'essaie d'utiliser ce code, il ne change pas une chose.

Bitmap b =  BitmapFactory.decodeResource(getResources(), R.drawable.navbarbg);
BitmapDrawable bd = new BitmapDrawable(getResources(), b);
bar.setBackgroundDrawable(bd);

Aussi, j'ai essayé ce code mais il ne fonctionne pas.

Resources res = getResources();
xpp =res.getXml(R.drawable.actionbar_background);
bitmapDrawable = (BitmapDrawable) BitmapDrawable.createFromXml (res, xpp);

Le contenu de actionbar_background.xml sont

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/navbarbg"
android:tileMode="repeat" />

Modifié:
J'ai utilisé ce code qui a bien fonctionné:

Bitmap bMap = BitmapFactory.decodeResource(res, R.drawable.action_bar_bg);
BitmapDrawable actionBarBackground = new BitmapDrawable(res, bMap);
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(actionBarBackground);

OriginalL'auteur Khaled Annajar | 2012-12-31