Created
November 8, 2014 03:37
-
-
Save stefanrusek/edc51afbf5a041893c18 to your computer and use it in GitHub Desktop.
This is a work around for the appcompat v21 on android 4.2.2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { | |
menu = new MenuWrapper(menu) { | |
private MenuItem fix(MenuItem item) { | |
try { | |
Field f = item.getClass().getDeclaredField("mEmulateProviderVisibilityOverride"); | |
f.setAccessible(true); | |
f.set(item, Boolean.FALSE); | |
} catch (Throwable e) { | |
e.printStackTrace(); | |
} | |
return item; | |
} | |
@Override | |
public MenuItem add(CharSequence title) { | |
return fix(super.add(title)); | |
} | |
@Override | |
public MenuItem add(int titleRes) { | |
return fix(super.add(titleRes)); | |
} | |
@Override | |
public MenuItem add(int groupId, int itemId, int order, CharSequence title) { | |
return fix(super.add(groupId, itemId, order, title)); | |
} | |
@Override | |
public MenuItem add(int groupId, int itemId, int order, int titleRes) { | |
return fix(super.add(groupId, itemId, order, titleRes)); | |
} | |
}; | |
} | |
inflater.inflate(R.menu.text_selection, menu); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My thoughts exactly... Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1?