Try adding a TextView to the menubar first and using setCompoundDrawables() to place the image on whichever side you want. Bond click activity to the textview in the end.
MenuItem item = menu.add(Menu.NONE, R.id.menu_item_save, 10, R.string.save);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS|MenuItem.SHOW_AS_ACTION_WITH_TEXT);
TextView textBtn = getTextButton(btn_title, btn_image);
item.setActionView(textBtn);
textBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// your selector here }
});
You can literally customize everything here:
public TextView getTextButton (String btn_title, Drawable btn_image) {
TextView textBtn = new TextView(this);
textBtn.setText(btn_title);
textBtn.setTextColor(Color.WHITE);
textBtn.setTextSize(18);
textBtn.setTypeface(Typeface.create("sans-serif-light", Typeface.BOLD));
textBtn.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
Drawable img = btn_image;
img.setBounds(0, 0, 30, 30);
textBtn.setCompoundDrawables(null, null, img, null);
// left,top,right,bottom. In this case icon is right to the text
return textBtn;
}