Skip to content Skip to sidebar Skip to footer

Alert Dialog With A Numeric Edittext Field

I am alerting the user with and alert dialog box that has an EditText field. AlertDialog.Builder alert = new AlertDialog.Builder(this); db.open(); Cursor f = db.getTitle(p

Solution 1:

I suggest you set some input filters and a key listener on the EditText, like so:

input.setFilters(new InputFilter[] {
    // Maximum 2 characters.
    new InputFilter.LengthFilter(2),
    // Digits only.
    DigitsKeyListener.getInstance(),  // Not strictly needed, IMHO.
});

// Digits only & use numeric soft-keyboard.
input.setKeyListener(DigitsKeyListener.getInstance());

Post a Comment for "Alert Dialog With A Numeric Edittext Field"