I want to change text color of menu item programmatically in option menu of ActionBar with its showAsAction parameter set to app:showAsAction="always"
.
I can change the text color of menu item when its app:showAsAction="never"
using this -
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem liveitem = menu.findItem(R.id.action_settings);
SpannableString s = new SpannableString(liveitem.getTitle().toString());
s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0);
liveitem.setTitle(s);
return true;
}
Any suggestion on how to change it if its "always"
.
I got a similar question here and here. but this answer is not concrete and cant be applied to all api versions.