Draws a toolbar in the appropriate place programmatically. - Android User Interface

Android examples for User Interface:Toolbar

Description

Draws a toolbar in the appropriate place programmatically.

Demo Code


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

public class Main {
  /**/*from   w  w  w .j av  a  2  s . c  om*/
   * Draws a toolbar in the appropriate place programmatically.
   * 
   * @param activity
   *          the activity you want to display the toolbar on.
   * @param toolbar
   *          your toolbar.
   * @param title
   *          the toolbar title.
   */
  public static void drawToolbar(AppCompatActivity activity, Toolbar toolbar, String title) {
    toolbar.setTitle(title);
    activity.setSupportActionBar(toolbar);
  }
}

Related Tutorials