Skip to content Skip to sidebar Skip to footer

Custom Edittextpreference And Setonpreferencechangelistener Not Called

My listener is not getting called for some reason? This is what I have: In Preference file I have a custom EditTextPreference:

Solution 1:

Found a solution, in my custom EditTextPreference I added a call to callChangeListener(value):

@Override
public void onBindDialogView(View view) {       
edittext = (EditText) view.findViewById(R.id.edittext);
edittext.setText(PreferenceManager.
        getDefaultSharedPreferences(view.getContext()).
        getString(getKey(), ""));       

ok_button = (Button) view.findViewById(R.id.ok_button);
ok_button.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        String value = edittext.getText().toString();
        if(callChangeListener(value)) {
            Editor editor = getEditor();
            editor.putString(getKey(), value);
            editor.commit();
            getDialog().dismiss();
        }
    }
});

Post a Comment for "Custom Edittextpreference And Setonpreferencechangelistener Not Called"