The public static Boolean isletterdigit (String str) {
Boolean isdigit = false;//defines a Boolean value that is used to indicate whether a numeric Boolean is included
Isletter = false;//defines a Boolean value that indicates whether to include the letter for
(int i=0; I
if (Character.isdigit (Str.charat (i))) { // Judge each character
IsDigit = True
using the method of judging numbers in the Char wrapper class if (Character.isletter (Str.charat (i))) { //judge each character Isletter = True using the method of judging letters in the Char wrapper class
;
String regex = "^[a-za-z0-9]+$";
Boolean isright = IsDigit && isletter&&str.matches (regex);
return isright;
}
Android determines whether edittext input numbers, Chinese, or alphabetic methods
String txt = edinput.gettext (). toString ();
Pattern p = pattern.compile ("[0-9]*");
Matcher m = p.matcher (TXT);
if (M.matches ()) {
Toast.maketext (main.this, "Enter a number", Toast.length_short). Show ();
P=pattern.compile ("[a-za-z]");
M=p.matcher (TXT);
if (M.matches ()) {
Toast.maketext (main.this, "input is a letter", Toast.length_short). Show ();
P=pattern.compile ("[\u4e00-\u9fa5]");
M=p.matcher (TXT);
if (M.matches ()) {
Toast.maketext (main.this, "input is Kanji", toast.length_short). Show ();