I have an edittext with input type set to number. I want to check if edittext is empty.
<EditText
android:id="@+id/noOfTranset"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Enter number:"
android:inputType="number"
android:textColor="@android:color/black"
android:maxLength="2"/>
Below is the code which I have tried but doesn't checks for empty edittext. What am I missing here? Thanks.
String numTrans = et1.getText().toString();
int transaction = Integer.parseInt(numTrans);
if(numTrans.trim().length() == 0 || numTrans.equals("") || numTrans == null){
// none of the above conditions check for empty edittext
}