I can seen to understand what I am doing wrong here.
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
Map<String, String> data = (Map<String, String>) getListView().getItemAtPosition(info.position);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
String admin = preferences.getString("Admin", null);
String user_ids = preferences.getString("userID", null);
menu.setHeaderTitle("Options");
menu.add(0, profile, 0, "Show Profile");
if (admin.equals("Admin")){
menu.add(0, add, 0, "Add Friend");
menu.add(0, pm, 0, "Send PM");
menu.add(0, warn, 0, "Send Warning");
menu.add(0, edit, 0, "Edit Post");
menu.add(0, delete, 0, "Delete Post");
menu.add(0, block, 0, "Block User");
}else if (data.get("pid").equals(user_ids)){
menu.add(0, edit, 0, "Edit Post");
}else{
menu.add(0, add, 0, "Add Friend");
menu.add(0, pm, 0, "Send PM");
menu.add(0, warn, 0, "Send Warning");
menu.add(0, block, 0, "Block User");
}
}
It errors out to
view.showContextMenu();
But if I comment out the IF ELSE statements it works. Confused.
May be you write
at ending of last if else condition.
and more you can see these links. Link1, Link2 and Link3