Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android check EditText

i have a EditText which always contains an integer...but sometimes also contains the text..how do I check if my string contains text fields in the EditText? Thanks in advance.

like image 696
Tony Avatar asked Jun 27 '26 00:06

Tony


1 Answers

I would approach the problem in the following manner:

String mEditText = mDisplay.getText().toString();
if(mEditText.matches("[0-9]+")) {
    // mEditText only contains numbers
} else {
    // mEditText contains number + text, or text only. 
}
like image 166
Raunak Avatar answered Jun 29 '26 12:06

Raunak