Java tutorial
//package com.java2s; import android.widget.TextView; public class Main { public static double getDoubleFrom(TextView view) { double val = getDoubleFrom(view.getText().toString()); return val; } public static double getDoubleFrom(String txt) { double val = 0; if (!"".equals(txt.replace(" ", "")) && !".".equals(txt) && !",".equals(txt) && !"-".equals(txt)) { val = Double.parseDouble(txt); } return val; } public static double getDoubleFrom(CharSequence chars) { double val = 0; if (!"".equals(chars.toString())) { val = Double.parseDouble(chars.toString()); } return val; } }