Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren0
Ways of checking text in the filling form
Hi! Please tell me, which option to check the presence of text in the filling view is more preferable: String s = editText.getText().toString(); // 1 option If(s.equalsIgnoreCase("")) { // some code} // 2 option If(s.matches("")) { // some code}
1 Antwort
+ 15
Best way to check edittext was filled or not is using TextUtils class.
In that class use static method isEmpty()
Example
String a = editText.getText().toString();
if(!TextUtils.isEmpty(a)){}