Reputation: 673
Good day.I have an simpliest pop up menu with simpliest item click handler.It all working good inside an activity and i have copy pasted same code inside the fragment and i am not able to get hold of item click listener.The issue is that,item click handler being fired,but it will never go through my statement.I tried with equals matching of their titles,no result,tried with item id's,no result...it just will not get working. Here is the code
PopupMenu popupMenu = new PopupMenu(getActivity(), view);
popupMenu.getMenu().add(0, 0, 0, getString(R.string.edit));
popupMenu.getMenu().add(0, 1, 0, getString(R.string.delete));
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case 0:
// TODO: 8/12/2016 handle edit
return true;
case 1:
Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT).show();
deleteDialog.show();
deletePost(mFeedModelArrayList.get(position).getId(), mFeedModelArrayList.get(position).getFileName());
return true;
}
return false;
}
});
popupMenu.show();
Items being showed but the Toast will never work,any clues whats wrong with this?
Upvotes: 1
Views: 826
Reputation: 673
Ok i got it working...put default:return false
and it finally worked
Upvotes: 1