Android : check if (numberDecimal) edittext is empty/null

on Sunday, September 21, 2014


My app crashes although the code seems correct :-O if I don't insert anything to editText1 app crashes



<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="18dp"
android:ems="10"
android:inputType="numberDecimal" >

String tmp1 = editText1.getText().toString().trim();
if(tmp1.isEmpty() || tmp1.length() == 0 || tmp1.equals("") || tmp1 == null){
editText1.setError("error");
}
else

0 comments:

Post a Comment