Android 自定义EditTextPreference。如何以及何时获取用于保存目的的文本
我正在写自定义编辑文本首选项 在我的CustomEditTextPreference中使用此代码:Android 自定义EditTextPreference。如何以及何时获取用于保存目的的文本,android,android-preferences,Android,Android Preferences,我正在写自定义编辑文本首选项 在我的CustomEditTextPreference中使用此代码: @Override protected void onDialogClosed(boolean shouldSave) { if (shouldSave) { String sValue = getText(); value = Float.parseFloat(sValue); peristValu
@Override
protected void onDialogClosed(boolean shouldSave) {
if (shouldSave) {
String sValue = getText();
value = Float.parseFloat(sValue);
peristValue();
}
}
sValue为空。那么如何从编辑中获取值呢?您可能应该使用
getEditText().getText().toString();
因为它本身获取当前SharedReference值,该值可能存在也可能不存在