Android Toolbar Action Icon Not Working
I have two Material Toolbars in my app, and I have two menu_main.xml and menu_main2.xml. The icon shows properly in both toolbars, but the action on one of the toolbar doesn't work
Solution 1:
toolbar2.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem arg0) {
if(arg0.getItemId() == R.id.whatever){
}
return false;
}
});
Solution 2:
Only the first toolbar will be picked up by onOptionsItemSelected since that's the only one you set as a supportActionBar. For the other toolbar, you will have to set click listeners for your items. As heloisasim suggested, you can use the setOnMenuItemClickListener method to do this.
Post a Comment for "Android Toolbar Action Icon Not Working"