Opening a JAR
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="User Account">
<EditTextPreference
android:key="user"
android:title="User Name"
android:summary="Your identi.ca screen name"
android:dialogTitle="Enter your identi.ca user name" />
<EditTextPreference
android:key="password"
android:title="Password"
android:summary="Your identi.ca account password"
android:password="true"
android:dialogTitle="Enter your identi.ca password" />
</PreferenceCategory>
</PreferenceScreen>
Note the use of android:password = "true" to turn the second one into a
password-style preference. Any EditText attributes found in the
EditTextPreference element are passed through to the EditText used in the
popup dialog.
Then, we need another EditPreference activity akin to the one we used in
LunchList – call it Patchy/src/apt/tutorial/two/EditPreferences.java:
package apt.tutorial.two;
import android.app.Activity;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class EditPreferences extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
We must not forget to update our AndroidManifest.xml file to reference the
new activity, so amend yours to look like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="apt.tutorial.two"
android:versionCode="1"
android:versionName="1.0">