在settings中添加一个新选项
1)packages/apps/Settings/res/xml /settings_header.xml中添加一个选项,代码如下
<header
android:id="@+id/modify_password"
android:fragment="com.android.settings.ModifyDeviveSettings"
android:icon="@drawable/ic_settings_about"
android:title="@string/about_settings" />
2)packages/apps/Settings/res/xml/modify_device.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/screen_settings"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<EditTextPreference
android:key="modify_password"
android:dialogTitle="change the password"
android:title="please input your new password"
android:summary="change password">
</EditTextPreference>
</PreferenceScreen>
3) packages/apps/Settings/src/com/android/settings添加一个类ModifyDeviveSettings.java 继承 SettingsPreferenceFragment
实现OnPreferenceChangeListener接口,在onCreate()方法中添加资源文件,addPreferencesFromResource(R.xml.modify_device);
我们可以在这个类中实现我们的功能
1)packages/apps/Settings/res/xml /settings_header.xml中添加一个选项,代码如下
<header
android:id="@+id/modify_password"
android:fragment="com.android.settings.ModifyDeviveSettings"
android:icon="@drawable/ic_settings_about"
android:title="@string/about_settings" />
2)packages/apps/Settings/res/xml/modify_device.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/screen_settings"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<EditTextPreference
android:key="modify_password"
android:dialogTitle="change the password"
android:title="please input your new password"
android:summary="change password">
</EditTextPreference>
</PreferenceScreen>
3) packages/apps/Settings/src/com/android/settings添加一个类ModifyDeviveSettings.java 继承 SettingsPreferenceFragment
实现OnPreferenceChangeListener接口,在onCreate()方法中添加资源文件,addPreferencesFromResource(R.xml.modify_device);
我们可以在这个类中实现我们的功能