Create Plain Toolbar No Title - Android android.app

Android examples for android.app:Toolbar

Description

Create Plain Toolbar No Title

Demo Code

import android.app.Activity;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class Main{

    public static Toolbar getToolbarPlainNoTitle(Activity activity,
            @IdRes int toolbarResId) {
        Toolbar layoutToolbar = (Toolbar) activity
                .findViewById(toolbarResId);
        Toolbar result = (Toolbar) activity
                .findViewById(R.id.tablet_toolbar);
        if (result != null) {
            if (layoutToolbar != null) {
                layoutToolbar.setVisibility(View.GONE);
            }// w w w. j av a2 s  .  c  o  m
            ((TextView) activity.findViewById(R.id.toolbar_title))
                    .setText(activity.getTitle());
            return result;
        }
        layoutToolbar.setTitle(null);
        return layoutToolbar;
    }

}

Related Tutorials