get Int from EditView - Android User Interface

Android examples for User Interface:TextView Value

Description

get Int from EditView

Demo Code


import android.util.Log;
import android.widget.EditText;

public class Main {
  public static int getInt(String intString) {
    try {//from   w  ww  . j  a  va2 s.c o  m
      return Integer.parseInt(intString);
    } catch (NumberFormatException e) {
      Log.wtf("FloatingButtons", e.toString());
      return 0;
    }
  }

  public static int getInt(EditText view) {
    return getInt(view.getText().toString());
  }
}

Related Tutorials