I have added a android.support.v7.widget.SwitchCompat
switch on Toolbar. Here is my code:
SwitchCompat layout file toolbar_switch.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.SwitchCompat
android:id="@+id/toolbar_switch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text=""/>
</RelativeLayout>
menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:id="@+id/action_clipboard_switch"
android:title=""
app:actionLayout="@layout/toolbar_switch"
android:checkable="true"
android:enabled="true"
app:showAsAction="always"/>
This code is just showing me a switch on Toolbar. But when I click on switch nothing happens. I doesn't even toggle.
I've also added a Toast to onClickListener but it doesn't work. Help!!!
EDIT Neither Switch nor SwitchCompat Works!