[Solved] Crash if digit is more than 9


@Fay Zan

Basically you don’t want user to input more than 9 digits for your field,
This can be achieved using two ways programmatically or using layout views properties,

In you xml simple give this attribute to your EditText

android:maxLength="9"

OR programmatically by checking the length of your field. for example suppose the id of your field is @id+/portNo

then do validation like this

private EditText mportNo;

inside your onCreate()

mportNo = (EditText) findViewById(R.id.portNo);
String portValue = mportNo.getText().toString();

if(portValue.length() > 9) {
    // throw error
}

1

solved Crash if digit is more than 9