I'm creating a form that the user must input name without contain number or other character.
Part of the code is:
bSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String tampSalesName = salesName.getText().toString();
String lala = cekHuruf(tampSalesName);
if(lala.equals("number")){
Toast.makeText(RegisterSales.this, "Name must letters", Toast.LENGTH_SHORT).show();
}
public String cekHuruf(String a){
String zzzz="";
String aaa="";
int ab=0;
for (int i = 0; i < a.length(); i++) {
int abc = i++;
aaa= a.substring(i, abc);
try {
ab = Integer.parseInt(aaa);
} catch (NumberFormatException sdef) {
// TODO: handle exception
zzzz="number";
}
}
return zzzz;
}
And it will open String.class and will show error:
private StringIndexOutOfBoundsException startEndAndLength(int start, int end) {
throw new StringIndexOutOfBoundsException(this, start, end - start);
}
The logic : If the first word is letter it will always tamp letter. So what your suggestion about edittext must letter. I already try several way from change the input type in xml and try to use method in android EditText alphabet-only validation but still cannot work.