preferencefragment

从两个方面记录①setting.xml的一点问题②viewpager和preferencefragment

一、setting.xml

<ListPreference
android:dialogTitle="请选择一项"
android:entries="@array/entries_list_preference"
android:entryValues="@array/entryvalues_list_preference"
android:key="list_preferenc"
android:summary="一个使用了列表对话框的例子"
android:title="请选择一项" />

其中 android:entries="@array/entries_list_preference"

 string.xml中
< string-array name = "entries_str" >
     < item >白菜</ item >
     < item >萝卜</ item >
     < item >豆芽</ item >
     < item >芹菜</ item >
   </ string-array
本例中

 在使用PreferenceActivity时,碰到配置文件的ListPreference有两个属性android:entries,android:entryValues。这两个属性其实就和html的option的显示内容和真实值一样。android:entries设置的内容是我们在设置时看到的内容,而android:entryValues就是保存在preferences.xml中的值。

如:

 

<string-array name="app_component_list">
        <item>@string/app_index</item>
        <item>@string/app_easy_calc</item>
        <item>@string/app_binary_change</item>
        <item>@string/app_area_change</item>
        <item>@string/app_loan_calc</item>
        <item>@string/app_tax_calc</item>
        <item>@string/app_exchange_rate</item>
    </string-array>
    <string-array name="app_component_list_value">
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>5</item>
        <item>6</item>
        <item>7</item>
    </string-array>----------------转


还有啊

<PreferenceCategory android:title="In-line preferences" >
<CheckBoxPreference
android:key="checkbox_preference"
android:summary="这是一个复选框"
android:title="复选框设置" />
</PreferenceCategory>
<PreferenceCategory android:title="Dialog-based preferences" >
<EditTextPreference
android:dialogTitle="请输入你最喜欢的种族"
android:key="edittext_preference"
android:summary="一个使用了编辑文本对话框的例子"
android:title="请输入你最喜欢的种族" />

<ListPreference
android:dialogTitle="请选择一项"
android:entries="@array/app_component_list_value"
androud:entryValues="@array/"
android:key="list_preferenc"
android:summary="一个使用了列表对话框的例子"
android:title="请选择一项" />
</PreferenceCategory>
<PreferenceCategory android:title="Launch preferences" >
<!-- This PreferenceScreen tag serves as a screen break (similar to page break in word processing). Like for other preference types, we assign a key here so it is able to save and restore its instance state. -->
<PreferenceScreen
android:key="screen_preference"
android:summary="展示另一个首选项配置页面"
android:title="页面首选项" >
<!-- 你可以在这里放置更多的首选项内容,将被在下一个页面呈现出来 -->
<CheckBoxPreference
android:key="next_screen_checkbox_preference"
android:summary="在另一个页面展示但出于同一个层级的首选项配置"
android:title="复选框设置" />
</PreferenceScreen>
<PreferenceScreen
android:summary="从一个意图中启动一个activity"
android:title="意图首选项" >
<intent
android:action="android.intent.action.VIEW"
android:data="http://www.baidu.com" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="Preference attributes" >
<CheckBoxPreference
android:key="parent_checkbox_preference"
android:summary="这是一个可见的父类"
android:title="父类复选框首选项" />
<!-- 子类的可见类型是由样式属性定义的 -->
<CheckBoxPreference
android:dependency="parent_checkbox_preference"
android:key="child_checkbox_preference"
android:layout="?android:attr/preferenceLayoutChild"
android:summary="这是一个可见的子类"
android:title="子类复选框首选项" />
</PreferenceCategory>


http://www.it165.net/pro/html/201410/23922.html

转载于:https://www.cnblogs.com/Cherrylalala/p/5962236.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值