I have this xml layout, I want to make the switch element unclickable (disabled) so that when a user tries to press it, it doesn't work. how can I do this?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/english"
android:textSize="18sp" />
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="18sp" />
</LinearLayout>
Add android:enabled="false"
to your Switch element.
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="18sp"
**android:enabled="false"** />