Java tutorial
//package com.java2s; import android.widget.EditText; public class Main { public static int parseInt(EditText editText) { return parseInt(editText, 0); } public static int parseInt(EditText editText, int defaultValueIfInputIsEmpty) { String inputText = editText.getText().toString(); return "".equals(inputText) ? defaultValueIfInputIsEmpty : Integer.parseInt(inputText); } }