Android复选框首选项和附加选项
是否可以设置android复选框首选项或列表首选项以向首选项屏幕添加更多或更少的项目?如果是的话,我怎样才能做到呢 例如,我有这样一个简单的布局:Android复选框首选项和附加选项,android,xml,sharedpreferences,android-preferences,preferencescreen,Android,Xml,Sharedpreferences,Android Preferences,Preferencescreen,是否可以设置android复选框首选项或列表首选项以向首选项屏幕添加更多或更少的项目?如果是的话,我怎样才能做到呢 例如,我有这样一个简单的布局: <ListPreference android:key="wallpaper-type" android:title="Choose Wallpaper Style" android:entries="@array/wpType" android:entryValues="@array/wpTypeValues"
<ListPreference
android:key="wallpaper-type"
android:title="Choose Wallpaper Style"
android:entries="@array/wpType"
android:entryValues="@array/wpTypeValues"
/>
此列表中有3个选项。我希望这样,如果您选择选项1,您可以选择不同的菜单项,因为每个项都有不同的参数,用户可以更新
同样,如果我有此选项:
<CheckBoxPreference
android:key="enable_brightness"
android:title="Enable Brightness Tap Menu"/>
因此,如果用户单击此复选框,则可以向视图中添加另一个首选项菜单
也许我在这方面完全错了,应该重新设计视图和选项的结构,或者是否可以最好使用xml填充动态选项。标准方法是定义
android:dependency
。“不可用”首选项显示为“已禁用”,而不是“已消失”
通常,如果您使用的是首选项,您希望通过设置android:persistent=“true”
这是一个样本
<CheckBoxPreference
android:title="@string/show_notifications_title"
android:key="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
<CheckBoxPreference
android:title="@string/show_file_size_error_title"
android:key="show_file_size_error"
android:dependency="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
标准方法是定义android:dependency
。“不可用”首选项显示为“已禁用”,而不是“已消失”
通常,如果您使用的是首选项,您希望通过设置android:persistent=“true”
这是一个样本
<CheckBoxPreference
android:title="@string/show_notifications_title"
android:key="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
<CheckBoxPreference
android:title="@string/show_file_size_error_title"
android:key="show_file_size_error"
android:dependency="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
标准方法是定义android:dependency
。“不可用”首选项显示为“已禁用”,而不是“已消失”
通常,如果您使用的是首选项,您希望通过设置android:persistent=“true”
这是一个样本
<CheckBoxPreference
android:title="@string/show_notifications_title"
android:key="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
<CheckBoxPreference
android:title="@string/show_file_size_error_title"
android:key="show_file_size_error"
android:dependency="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
标准方法是定义android:dependency
。“不可用”首选项显示为“已禁用”,而不是“已消失”
通常,如果您使用的是首选项,您希望通过设置android:persistent=“true”
这是一个样本
<CheckBoxPreference
android:title="@string/show_notifications_title"
android:key="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
<CheckBoxPreference
android:title="@string/show_file_size_error_title"
android:key="show_file_size_error"
android:dependency="show_notifications"
android:persistent="true"
android:defaultValue="true"/>
这正是我需要的,谢谢!还感谢你的持续提示,这为我节省了一些调试的时间!这正是我需要的,谢谢!还感谢你的持续提示,这为我节省了一些调试的时间!这正是我需要的,谢谢!还感谢你的持续提示,这为我节省了一些调试的时间!这正是我需要的,谢谢!还感谢你的持续提示,这为我节省了一些调试的时间!