I have an ImageView that I attach to a MenuItem as its ActionView (the item appears in the ActionBar). The layout for this vi
You generally want to pass whatever (ViewGroup sub-class) you're going to be adding actionView to in to inflate. in order to get actionView back from the inflate call and not the parent you'll want to add a 3rd parameter, false, so that it won't add the inflated view to the parent.
ImageView actionView =
(ImageView)layoutInflater.inflate(R.layout.action_view_layout, parent, false);
// .. do whatever you like with actionView and then add it to it's parent
menuItem.addActionView(actionView)
There's a pretty good tutorial here that goes about things a little differently. It's specifying action_view_layout as part of menu.xml with something like:
android:actionLayout="@layout/action_view_layout"
That may also work for you provided you're always using the same layout. if you go that route you'd be able to get the ActionView by doing
ImageView actionView = menu.findItem(R.id.whatever).getActionView();