get Double From EditText - Android User Interface

Android examples for User Interface:EditText

Description

get Double From EditText

Demo Code


//package com.java2s;

import android.widget.EditText;

public class Main {
    private static final Integer ZERO = 0;

    public static Double getDoubleFrom(EditText editText) {
        String stringValueFromEditText = getStringFrom(editText);
        return stringValueFromEditText.isEmpty() ? ZERO : Double
                .valueOf(stringValueFromEditText);

    }/* ww  w.  j  av a 2s .co m*/

    public static String getStringFrom(EditText editText) {
        return editText.getText().toString();
    }
}

Related Tutorials