set ActionBar Color Form Res - Android User Interface

Android examples for User Interface:ActionBar Color

Description

set ActionBar Color Form Res

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;

public class Main {
    public static void setActionBarColorFormRes(Context context,
            Activity activity, int color) {
        activity.getActionBar().setBackgroundDrawable(
                new ColorDrawable(context.getResources().getColor(color)));
        activity.getActionBar().setDisplayShowTitleEnabled(false);
        activity.getActionBar().setDisplayShowTitleEnabled(true);
        refreshActionBar(activity);//w  ww  .j a v a 2  s. c om
    }

    public static void refreshActionBar(Activity activity) {
        activity.getActionBar().setDisplayShowTitleEnabled(false);
        activity.getActionBar().setDisplayShowTitleEnabled(true);
    }
}

Related Tutorials