Created
October 16, 2015 19:56
-
-
Save sibelius/7ca0b757492ff6740dec to your computer and use it in GitHub Desktop.
Custom Action Provider to show just a submenu to a menu item
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
public class MyActionProvider extends ActionProvider { | |
private Context mContext; | |
public MyActionProvider(Context context) { | |
super(context); | |
mContext = context; | |
} | |
@Override | |
public View onCreateActionView() { | |
//LayoutInflater layoutInflater = LayoutInflater.from(mContext); | |
return null; | |
} | |
@Override | |
public void onPrepareSubMenu(SubMenu subMenu) { | |
super.onPrepareSubMenu(subMenu); | |
subMenu.clear(); | |
subMenu.add("menu 1"); | |
subMenu.add("menu 2"); | |
subMenu.add("menu 3"); | |
} | |
@Override | |
public boolean hasSubMenu() { | |
return true; | |
} | |
@Override | |
public boolean onPerformDefaultAction() { | |
return super.onPerformDefaultAction(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment