码迷,mamicode.com
首页 > 其他好文 > 详细

preferencefragment

时间:2016-10-14 23:29:02      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:

从两个方面记录①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

preferencefragment

标签:

原文地址:http://www.cnblogs.com/Cherrylalala/p/5962236.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!