Android Custom Toolbar OnOptionsItemSelected Not Working
I got two similar buttons Copy
Menu item:
<item
android:id="@+id/myswitch"
android:title=""
app:showAsAction="always"
app:actionLayout="@layout/toggle" />
Active layout must implement:
android:clickable="false"
My toggle action layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false">
<ToggleButton
android:id="@+id/actionbar_service_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOn="Discovery"
android:textOff="Favourite"
android:clickable="false"/>
</RelativeLayout>
Solution 2:
Accessing the menu on the toolbar item can work.
//kotlin
toolbar.menu.getItem(itemIndex).setOnMenuItemClickLister {}
You can do this for all the menu items
Post a Comment for "Android Custom Toolbar OnOptionsItemSelected Not Working"