prefs: added PreferenceWithValue to show string

mediatek_nojit
Georg Lukas 2014-12-29 08:41:17 +01:00
rodzic 2538225759
commit 27604703a6
1 zmienionych plików z 33 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,33 @@
package de.duenndns;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
public class PreferenceWithValue extends Preference {
CharSequence mSummary;
public PreferenceWithValue(Context context, AttributeSet attrs) {
super(context, attrs);
}
public PreferenceWithValue(Context context) {
super(context);
}
private void setSummaryToText(String text) {
if (mSummary == null)
mSummary = getSummary();
if (text == null || text.length() == 0)
setSummary(mSummary);
else
setSummary(mSummary + ": " + text);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
setSummaryToText(getSharedPreferences().getString(getKey(), ""));
}
}