EditTextPreference:
效果图:
[img]

[/img]
当我们点击主页面的输入名称时,就会弹出该对话框,让我们输入名称。
代码:
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="edittext_screen" android:title="屏幕标题" android:summary="屏幕简要说明" > <EditTextPreference android:dialogTitle="输入您的名称:" android:key="editTitlePreference" android:summary="简要说明" android:title="输入名称" ></EditTextPreference> </PreferenceScreen>
RingtonePreference:
效果图
[img]

[/img]
代码:
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="edittext_screen" android:title="屏幕标题" android:summary="屏幕简要说明" > <!-- android:ringtoneType 设置响铃模式,主要包括ringtone、notification、alarm、all android:showSilent 是否显示静音 注意,如果模拟器中没有铃声的话,我们可以自己添加。将音乐复制到SD卡上,然后转到android media player应用程序,选择该音乐, 单击menu,然后选择 uses as ringtone --> <RingtonePreference android:key="ringtonePreference" android:summary="简要说明" android:title="选择系统铃声" android:ringtoneType="alarm" android:showSilent="true" ></RingtonePreference> </PreferenceScreen>
我们看看后台的xml中是如何存储的 <?xml version='1.0' encoding='utf-8' standalone='yes' ?> <map> <string name="ringtonePreference">content://settings/system/alarm_alert</string> </map> 这里我们可要注意了哦,ringtonePreference的值是一个uri字符串