I am trying to show quick action after click on action bar item, so I need to get a parent view to to know where should be quick action shown.
Here is my code:
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
prepareQuickActions();
MenuItem menuItem = menu.add("Text");
menuItem.setIcon(R.drawable.ic_action_dialog_map)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(final MenuItem item) {
quickAction.show(item.getActionView());
return true;
}
});
}
Problem is that item.getActionView()
returns null. Where could be a
problem? Bug in a library?
By default action view of a MenuItem is null because it is just sort of an alternative that you can use to customize. As far as I know there is no way to get to the view of the MenuItem. A workaround I know would be to set the action view first to what you want it to look like (and you can style it any way you like) and then it wont return null ...
Also see Different look/style for specific menu item on ActionBar
Could be that your menu.xml is not correct. Check your path for android:actionViewClass: