mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
android preferences Fix preference summary not updated
This commit is contained in:
parent
721a2c9d6c
commit
c5f27719fe
@ -19,7 +19,6 @@
|
|||||||
<string name="error_articleurlnotfound">Error: Loading article (Url: %1$s) failed.</string>
|
<string name="error_articleurlnotfound">Error: Loading article (Url: %1$s) failed.</string>
|
||||||
<string name="pref_display_title">Display</string>
|
<string name="pref_display_title">Display</string>
|
||||||
<string name="pref_zoom_title">Zoom</string>
|
<string name="pref_zoom_title">Zoom</string>
|
||||||
<string name="pref_zoom_summary">%s</string>
|
|
||||||
<string name="pref_zoom_dialogtitle">Zoom</string>
|
<string name="pref_zoom_dialogtitle">Zoom</string>
|
||||||
<string-array
|
<string-array
|
||||||
name="pref_zoom_entries">
|
name="pref_zoom_entries">
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="pref_zoom"
|
android:key="pref_zoom"
|
||||||
android:title="@string/pref_zoom_title"
|
android:title="@string/pref_zoom_title"
|
||||||
android:summary="@string/pref_zoom_summary"
|
|
||||||
android:dialogTitle="@string/pref_zoom_dialogtitle"
|
android:dialogTitle="@string/pref_zoom_dialogtitle"
|
||||||
android:entries="@array/pref_zoom_entries"
|
android:entries="@array/pref_zoom_entries"
|
||||||
android:entryValues="@array/pref_zoom_entryvalues"
|
android:entryValues="@array/pref_zoom_entryvalues"
|
||||||
|
@ -1,15 +1,39 @@
|
|||||||
package org.kiwix.kiwixmobile;
|
package org.kiwix.kiwixmobile;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
|
||||||
|
|
||||||
public class KiwixSettings extends PreferenceActivity {
|
public class KiwixSettings extends PreferenceActivity {
|
||||||
|
ListPreference prefList;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
|
||||||
|
prefList = (ListPreference) findPreference("pref_zoom");
|
||||||
|
prefList.setDefaultValue(prefList.getEntryValues()[0]);
|
||||||
|
String ss = prefList.getValue();
|
||||||
|
if (ss == null) {
|
||||||
|
prefList.setValue((String)prefList.getEntryValues()[0]);
|
||||||
|
ss = prefList.getValue();
|
||||||
|
}
|
||||||
|
prefList.setSummary(prefList.getEntries()[prefList.findIndexOfValue(ss)]);
|
||||||
|
|
||||||
|
|
||||||
|
prefList.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
prefList.setSummary(prefList.getEntries()[prefList.findIndexOfValue(newValue.toString())]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user