Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { toolbar.setTitle(R.string.app_name); setSupportActionBar(toolbar); }
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar); toolbar.setTitle("Title Goes Here");
public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar actionbar = (Toolbar) findViewById(R.id.actionbar); if (null != actionbar) { actionbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha); actionbar.setTitle(R.string.title_activity_settings); actionbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NavUtils.navigateUpFromSameTask(SettingsActivity.this); } }); // Inflate a menu to be displayed in the toolbar actionbar.inflateMenu(R.menu.settings); } } }
toolbar.setTitle("Card Toolbar"); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override
nitView(); if (toolbar != null) { toolbar.setTitle("Navigation Drawer"); setSupportActionBar(toolbar);
toolbar.setTitle(""); mTitle = (TextView) toolbar.findViewById(R.id.toolbar_title); mTitle.setText(title);
Toolbar toolbar = findViewById(R.id.my_awesome_toolbar); //Get rid of the title drawn by the toolbar automatically toolbar.setTitle(""); TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setTextColor(Color.BLUE);
toolbar.setTitle("Title");
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("YOUR_TITLE"); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); public static void settitle(String title){ toolbar.setTitle(title); }
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { toolbar.setTitle(R.string.app_name); setSupportActionBar(toolbar); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scrolling); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // erase the expanded title getSupportActionBar().setTitle(null); // set the title on the other pinned toolbar Toolbar titleToolbar = (Toolbar) findViewById(R.id.titleToolbar); titleToolbar.setTitle("This is the real title"); }
Toolbar toolbar; toolbar = (Toolbar) findViewById(R.id._toolbar); setSupportActionBar(toolbar); toolbar.setTitle(Html.fromHtml(" <font color='#555555'> Your Title </font>")); getSupportActionBar().setDisplayShowTitleEnabled(true);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_layout); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); }
@Override public void onAttach(Activity activity) { super.onAttach(activity); Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar); toolbar.setTitle("Your Custom Title"); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setTitleForView(View view, String text) { ((Toolbar) view).setTitle(text); } }
Toolbar toolbar = findViewById(R.id.my_awesome_toolbar); //Get rid of the title drawn by the toolbar automatically toolbar.setTitle(""); TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setTextColor(Color.BLUE);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // Title and subtitle toolbar.setTitle(R.string.about_toolbar_title); toolbar.setSubtitle("My Subtitle"); activity.setSupportActionBar(toolbar);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar); toolbar.setTitle(R.string.action_settings); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { Toolbar tb=view.findViewById(R.id.toolbar); tb.inflateMenu(R.menu.actions_edit); tb.setOnMenuItemClickListener(item -> (onOptionsItemSelected(item))); if (((Contract)getActivity()).shouldShowTitle()) { tb.setTitle(R.string.app_name); } deleteItem=tb.getMenu().findItem(R.id.delete); }