Checking if a button has been clicked
问题 How to load menu depend on button was clicked? Any idea, solution? @Override public boolean onCreateOptionsMenu(final Menu menu) { menu.clear(); if(button.**isclicked**) { getMenuInflater().inflate(R.menu.menu_main, menu); } else { getMenuInflater().inflate(R.menu.test, menu); } return true; } 回答1: Put a boolean field in your activity and change whenever you click button . Depends if its true or false show or not your menu UPDATE //declare boolean boolean clicked=false; //my button clic