This is the settings_red.xml code
<!-- Usuario de la red -->
<EditTextPreference
android:key="usuario_reducf"
android:selectAllOnFocus="true"
android:singleLine="true"
android:summary="@string/pref_usuario_resumen"
android:title="@string/pref_usuario_titulo"
/>
<!-- Password de red -->
<EditTextPreference
android:inputType="textPassword"
android:key="contraseña_reducf"
android:selectAllOnFocus="true"
android:singleLine="true"
android:summary="@string/pref_contraseña_resumen"
android:title="@string/pref_contraseña_titulo" />
This code will take it out of stackoverflow in English but it gives me null or it will not instantiate the editTextPreference
// Reutilización del fragmento
String settings = getArguments().getString("settings");
if ("generales".equals(settings)) {
addPreferencesFromResource(R.xml.settings_gen);
} else if ("reducf".equals(settings)) {
addPreferencesFromResource(R.xml.settings_red);
user = (EditTextPreference) findPreference("ususario_reducf");
password = (EditTextPreference)findPreference("contraseña_reducf");
user.setText(getPreferenceScreen().getSharedPreferences().getString("username", ""));
password.setText(getPreferenceScreen().getSharedPreferences().getString("password", ""));
}
For them to understand better what happens is that at the beginning I ask for username and password to authenticate in a network and I want it to store it in sharedpreferences once it enters the configuration of the apk load the ones it has saved , so I leave blank. Any help?