i was trying to make the custom overflow button with new drawable source start an activity instead of showing drop down menu. I've read somewhere that I have to make sure there's only one item in onOptionItemSelected, so here's my code:
public boolean onOptionsItemSelected(MenuItem item) {
// Inflate the menu; this adds items to the action bar if it is present.
switch(item.getItemId()){
case R.id.logout_button:
Intent i = new Intent(PetVacActivity.this, LoginActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
SharedPreferences sharedpreferences = getSharedPreferences(LoginActivity.MyPREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.clear();
editor.commit();
startActivity(i);
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
but unfortunately, my app still showing the overflow button, but there's only one blank drop down menu like this
instead of directly start my activity, i have to click the dropdown menu first to activate my intent