First add this icon in you action R.menu... file and set the visibility as false.
Have a boolean instance variable in our java file.
private boolean isTickVisible = false;
Then you need to override OnPrepareOptions menu like below and set the visibility of the tick menu.
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
MenuItem someMenuItem = menu.findItem(R.id.tick_menu_item);
someMenuItem.setVisible(isTickVisible);
}
Finally onClick event of your button do the following :
isTickVisible = true;
invalidateOptionsMenu(); //this will redraw your menu.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…