4
我想要一些其他首選項取決於調用意圖進行某些處理的首選項。Android首選項,如何設置對自定義首選項的依賴
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<Preference
android:key="urlpref"
android:summary="summary here"
android:title="title here" >
<intent
android:action="android.intent.action.VIEW"
android:data="http://www.android.com"
android:targetClass="com.example.app.popupactivity"
android:targetPackage="com.example.app" />
</Preference>
<CheckBoxPreference
android:defaultValue="false"
android:key="enablepref"
android:summary="Summary"
android:title="title"
android:dependency="urlpref"/>
基本上第一偏好啓動這需要從用戶輸入,並將其保存到sharedpreference的活性。
現在我的複選框沒有啓用或禁用基於此。我也嘗試添加到urlpref
android:disableDependentsState="true"
那麼,正確的方法是什麼?
在主Activity的onCreate()方法中,只需調用PreferenceManager.setDefaultValues()方法。 PreferenceManager.setDefaultValues(this,R.xml.preference,false); – TheFlash 2013-05-07 09:32:16
這不工作@Pratik – 2013-05-07 10:33:05
這就是我解決它的方法。 我所做的是在項目上註冊一個sharedpreference監聽器,並且每當改變手動啓用或禁用相關項目。 – 2013-05-15 10:22:26