setContentView(R.layout.activity_testing_action_bar); toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("Toolbar Test 1"); toolbar.inflateMenu(R.menu.menu_testing_action_bar); toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.nav_tint)); public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { toolbar.setTitle("Toolbar Test 2"); toolbar.getMenu().clear(); toolbar.inflateMenu(R.menu.menu_settings); toolbar.setBackgroundColor(getResources().getColor(R.color.red)); } else { toolbar.setTitle("Toolbar Test 1"); toolbar.getMenu().clear(); toolbar.inflateMenu(R.menu.menu_testing_action_bar);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.feedback_activity); Toolbar tb = (Toolbar) findViewById(R.id.fb_toolbar); setSupportActionBar(tb); //Parse a color with any hex code tb.setBackgroundColor(Color.parseColor("#FFFFFF")); //Set title tb.setTitle("Your title"); }
Toolbar t = new Toolbar(); myForm.setToolbar(t); t.setTitle("My title"); Command back = new Command("back") { @Override public void actionPerformed(ActionEvent evt) { myForm.showBack(); } }; myForm.setBackCommand(back); t.addCommandToLeftBar(back);
Toolbar t = new Toolbar(); f.setToolBar(t); Command news = new Command("News", myIcon) { @Override public void actionPerformed(ActionEvent evt) { } }; news.putClientProperty("uiid", "BackCommand"); f.setBackCommand(news); t.addCommandToLeftBar(news); t.setTitle("My Form");