Set Toolbar as support ActionBar - Android User Interface

Android examples for User Interface:Toolbar

Description

Set Toolbar as support ActionBar

Demo Code


import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public class Main{
    /**/*from  w  w  w . j  a  v  a2s .  c o  m*/
     * Set Toolbar as support ActionBar
     *
     * @param activity AppCompatActivity
     * @param toolbar compat Toolbar
     * @param resId layout of Toolbar
     */
    public static void setToolbarAsSupportActionBar(
            AppCompatActivity activity, Toolbar toolbar, int resId) {
        toolbar = (Toolbar) activity.findViewById(resId);
        activity.setSupportActionBar(toolbar);
    }
}

Related Tutorials