Create Plain Toolbar - Android android.app

Android examples for android.app:Toolbar

Description

Create Plain Toolbar

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 getToolbarPlain(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);
            }//  ww w.j av a2s.com
            ((TextView) activity.findViewById(R.id.toolbar_title))
                    .setText(activity.getTitle());
            return result;
        }
        layoutToolbar.setTitle(activity.getTitle());
        return layoutToolbar;
    }

}

Related Tutorials