Use android:enabled="false"
from your XML, or setEnabled()
in Java code.
How do I make an Android CheckBoxPreference unclickable?
-
11-04-2022 - |
题
Here's my code:
<PreferenceCategory
android:summary="Fade information"
android:title="Fade Effects">
<CheckBoxPreference
android:title="Fade In/Out"
android:defaultValue="false"
android:key="fadeIn"/>
<CheckBoxPreference
android:title="Heartbeat"
android:defaultValue="false"
android:key="heartbeat" />
<CheckBoxPreference
android:title="Pulse"
android:defaultValue="false"
android:key="pulse" />
<CheckBoxPreference
android:title="None"
android:defaultValue="true"
android:key="none" />
</PreferenceCategory>
I'm basically trying to figure out how to make those CheckBoxes appear as they are, but having them unclickable by the user.
解决方案 2
其他提示
Using android:enabled="false"
is incorrect as this actually completely disables a View
(it also greys it out which is the main issue). What you want to do instead is:
android:clickable="false"
This simply stops the user clicking the View
but doesn't officially 'disable' it. I think that's more what you are looking for.
You can use android:selectable="false"
in xml if you don't wish to gray out the CheckboxPreference.
不隶属于 StackOverflow