Search code examples
javaandroidcheckboxpreference

How do I make an Android CheckBoxPreference unclickable?


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.


Solution

  • Use android:enabled="false" from your XML, or setEnabled() in Java code.