<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_save"
android:title="@string/action_save"
android:icon="@drawable/ic_action_save"
android:orderInCategory="100"
app:showAsAction="always"
app:actionLayout="@layout/layout_menu_save"/>
</menu>
This is my function code
fun isAdvanceSearchButtonEnabled(bool: Boolean) {
menu?.getItem(0)?.setEnabled(bool)
(menu?.getItem(0) as TextView).setTextColor(Color.parseColor("#000000"))
}
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
inflater?.inflate(R.menu.menu_cs_search_advance, menu)
this.menu = menu
super.onCreateOptionsMenu(menu, inflater)
}
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.action_advance_search_query -> {
}
}
return super.onOptionsItemSelected(item)
}
I want to change Menu item color on based of condition but I am not able to get I will case menu item as textview or how to change menu item text color I tried as type cast but it show null can not cast as text view please suggest me how I will change menu item text color problematically in Android