Ideally, if your EditText will only accept integers then you should set inputType property to either:
eg. something like this:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editTextCustomerPin"
android:layout_marginTop="20dp"
android:inputType="numberSigned"
android:textSize="16dp" android:hint="@string/enterCustomerPin"
android:layout_gravity="center_horizontal"/>
Now in your activity, you can always do:
EditText myEditText = (EditText) findViewById(R.id.editTextCustomerPin);
String editTextContent = myEditText.getText().toString();
if (editTextContent.length() > 0) {
int num = Integer.parseInt(num);
//Do your processing
} else {
//Show error message, eg. a toast or an alert dialog
}
onCreate()method ?