Skip to content

Commit

Permalink
fixed MenuItem crash below API 11
Browse files Browse the repository at this point in the history
  • Loading branch information
cuttingedge03 committed Mar 24, 2014
1 parent dd1c47e commit 77d3394
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/src/main/java/im/tox/antox/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,10 @@ public void onPanelClosed(View view) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(activeTitle);
MenuItem af = menu.findItem(R.id.add_friend);
af.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
MenuItemCompat.setShowAsAction(af,MenuItem.SHOW_AS_ACTION_NEVER);
MenuItem ag= menu.add(666, 100, 100, R.string.add_to_group);
ag.setIcon(R.drawable.ic_action_add_group).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
ag.setIcon(R.drawable.ic_action_add_group);
MenuItemCompat.setShowAsAction(ag,MenuItem.SHOW_AS_ACTION_ALWAYS);
ag.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Expand All @@ -709,7 +710,8 @@ public void onPanelOpened(View view) {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
setTitle(R.string.app_name);
MenuItem af = menu.findItem(R.id.add_friend);
af.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
MenuItemCompat.setShowAsAction(af,MenuItem.SHOW_AS_ACTION_IF_ROOM);
// af.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
/*af.setIcon(R.drawable.ic_action_add_person);
af.setTitle(R.string.add_friend);*/
menu.removeGroup(666);
Expand Down

0 comments on commit 77d3394

Please sign in to comment.