How To Setonclicklistener() To Ok Button Of An Edittextpreference Dialog?
Possible Duplicate: how to call the ok button in the EditTextPreference I want to validate the Inputs (enter 6 digits) of an EditTextPreference dialog box. This is how my (relev
Solution 1:
The author of the solution has moved his project from Google Code to GitHub. You can find the new project at https://github.com/Knickedi/android-toolbox and the links to the two files he was referring to validating DialogPreference
and validating EditTextPreference
Solution 2:
This could be achieved using setOnPreferenceChangeListener()
publicUpdatePasswordPreference(Context context, AttributeSet attrs) {
this.setOnPreferenceChangeListener(newOnPreferenceChangeListener()
{
@OverridepublicbooleanonPreferenceChange(Preference preference, Object newValue)
{
MobicopLogger.d("Preference input changed");
try
{
if(newValue.toString().length() != 6)
returnfalse;
elsereturntrue;
}
catch(Exception e)
{
returnfalse;
}
}
});
}
Solution 3:
create a custom layout and apply it to the preference by the following override method :
@OverrideprotectedvoidonPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder); //To change body of overridden methods use File | Settings | File Templates.
builder.setView(LayoutInflater.from(ctx).inflate(R.layout.custome_preference_layout,null));
}
Post a Comment for "How To Setonclicklistener() To Ok Button Of An Edittextpreference Dialog?"