There is another solution for customizing the appearance of the preferences.
Design a normal XML layout with buttons or whatever you want to add to the standard preferences. Include a ListView
in your layout and give it the ID @android:id/list
.
Let's say we call the layout file res/layout/main.xml
. It could look something like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button android:text="This is a button on top of all preferences."
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
In your PreferenceActivity
, add these two lines to your onCreate
:
addPreferencesFromResource(R.xml.preferences);
setContentView(R.layout.main);
The ListView
in your layout will then be replaced by the preferences defined the usual way in res/xml/preferences.xml
分享到:
相关推荐
安卓PreferenceScreen使用详细Demo,本Demo对应博文https://blog.csdn.net/qXing123456789/article/details/84962172
android 设置界面偏好设置,里面包括基础用法和自定义Preference举例
集合了几个经典的效果实现。... 2、自定义位置和样式的半透明对话框,实现悬浮...6、preferenceScreen实现设置效果。 7、spanableString设置超链接,字体,颜色等效果实现。 学习android应用开发的可以参考一下,很有用的。
大家可能遇到,PreferenceCategory默认是黑色背景,如何我们更换了PreferenceScreen的背景,那么这种分隔栏看上去很丑,那么怎么更改背景呢?我们可以通过自定义VIEW来实现。 代码如下: public class ...
声明简单,但是如何从PreferenceScreen或者PreferenceCategory中删除一个Preference会简单么.为什么有些人写的就无法删除成功呢?本文将从Android源码实现来分析一下. 声明文件 代码如下: <?xml version=”1.0″ ...
使用PreferenceScreen控件 继承ListPreference的MutiSelectListPreference,可以多选
google提供的android2.3里面,只能在GSM/WCDMA情况下才能从“设置”->“无线和网络”->“移动网络”->“接入点名称”中选择不同的...PreferenceScreen android:key=”button_apn_key” android:title=”@string/apn_se
使用xml的喜好包含文件PreferenceScreen与和内PreferenceScreen 处理PreferenceScreen打开 处理方向更改而无需在片段上保留实例或锁定Activity 处理android后退按钮以转到上一个屏幕 待办的。 去做 汉德回到首页...
今天主要研究了一下设置中的Preferencescreen应用,它不仅可以作为设置界面显示,而且还能够启动activity,下面主要是对启动activity的介
偏好+ Android 首选项的扩展,可创建其他首选项类型,包括EditIntPreference 、 EditFloatPreference...用法首选项.xml < PreferenceScreen xss=removed> < com .mapzen.prefsplus.EditIntPreference android
闪耀 应用程序了解android平台的详细信息 #发现路线图 HttpUrlConnection ...通过首选项xml文件并使用根元素PreferenceScreen-以及其他子元素(如EditTextPreference,ListPreference)来制作首选项,它
正文:首先PreferenceScreen是一个xml文件于res/xml目录下,不属于layout文件。要插入layout,有两种方法。 1.使用Preference的android:@layout属性 1)xml文件中preference的添加 代码如下: <Preference android...
ShowCaseAndroid android 应用程序的自动化“ShowCase”和“Tips Baloons” 已知的问题 contentDescription 属性,在 PreferenceScreen' xml 中定义,被 android 忽略,因此只有 xml 定义的提示有效
Android SubSettings跳转 <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > android:key="settings" ...</PreferenceScreen>
带工具栏的嵌套PreferenceScreen和处理配置正确更改(恢复状态) 没有API更改(仅用于技巧) 安装(Gradle依赖) compile 'com.fnp:material-preferences:0.1.4' 用法 请检查和下面的必需步骤。 样式 对于棒棒糖...