Skip to content Skip to sidebar Skip to footer

Change Homeasupindicator Dynamically

I build an app with four tabs and, as a consequence, four fragments. In the first fragment, I have a sliding menu and I throw with a custom icon in the actionbar. The problem is th

Solution 1:

You can use the following in your fragments:

Actionbarab= getActivity().getActionBar();
ab.setIcon(icon);

Where icon is a Drawable or a resource id, when the up indicator is a part of your icon. You can also use setHomeAsUpIndicator if you use API level > 11:

getActivity().getActionBar().setHomeAsUpIndicator(resId);

If your API level is lower, then I suggest you make use of ActionbarSherlock.

Post a Comment for "Change Homeasupindicator Dynamically"