偏好设置xml中的android:visibility属性不起作用?(Android 2.3) [英] android:visibility attribute in preferences xml not working? (Android 2.3)

查看:95
本文介绍了偏好设置xml中的android:visibility属性不起作用?(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 Views 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆