Skip to content

Instantly share code, notes, and snippets.

@amadeu01
Created February 18, 2018 15:37
Show Gist options
  • Save amadeu01/babeaa8669e610d880ca86177c3eb000 to your computer and use it in GitHub Desktop.
Save amadeu01/babeaa8669e610d880ca86177c3eb000 to your computer and use it in GitHub Desktop.
Int Edit Text Preferences
/**
* @Author Amadeu Cavalcante Filho
* @Date 29/12/2017
* @Email amadeu01@gmail.com
*/
public class IntEditTextPreference extends EditTextPreference {
public IntEditTextPreference(Context context) {
super(context);
}
public IntEditTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public IntEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected String getPersistedString(String defaultReturnValue) {
return String.valueOf(getPersistedInt(-1));
}
@Override
protected boolean persistString(String value) {
return persistInt(Integer.valueOf(value));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment