Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;

import android.graphics.drawable.ColorDrawable;

public class Main {
    /**
     * Set action bar background
     *
     * @param activity   The activity to set ActionBar background to.
     * @param resColorId The Drawable color to set the ActionBar to.
     */
    public static void setActionBarBackground(Activity activity, int resColorId) {
        // change action bar color
        activity.getActionBar()
                .setBackgroundDrawable(new ColorDrawable(activity.getResources().getInteger(resColorId)));
        activity.getActionBar().setDisplayShowTitleEnabled(false);
        activity.getActionBar().setDisplayShowTitleEnabled(true);
    }
}