偏好设置xml中的android:visibility属性不起作用?(Android 2.3) [英] android:visibility attribute in preferences xml not working? (Android 2.3)
问题描述
例如下面这个小的preference.xml文件:
Take for example this small preference.xml file:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/sig_title" xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference android:entries="@array/text_display_entries" android:title="@string/sig_style" android:key="text_style" android:entryValues="@array/text_display_values" />
<CheckBoxPreference android:title="@string/custom_font" android:key="tweaks_text" />
<CheckBoxPreference android:title="@string/col_random" android:key="random_color_pref" />
<CheckBoxPreference android:visibility="invisible" android:enabled="false" android:title="@string/sig_show" android:key="show_sig" />
</PreferenceScreen>
最后一个复选框的属性android:visibility ="invisible"不起作用;此属性(或因该原因而消失)不适用于首选项?
The attribute android:visibility="invisible" for the last checkbox doesn't work; this attribute (or gone for that matter) doesn't work for preferences?
我在代码中没有任何东西可以弄乱它的可见性,只是好奇为什么它不起作用.
I don't have anything in the code to mess with its visibility, just curious why this doesn't work.
推荐答案
android:visibility
用于显示和隐藏 View
,但对于无效>首选项
. Preferences
的文档列出了可用的XML属性,但都不是您想要的.
android:visibility
is used to show and hide View
s but it's not valid for a Preference
. The documentation for Preference
lists the available XML attributes, but none of them are what you want.
是,但是可以通过编程从 PreferenceScreen
中添加和删除首选项.
It is, however, possible to add and remove preferences from a PreferenceScreen
programatically.
这篇关于偏好设置xml中的android:visibility属性不起作用?(Android 2.3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!