get EditText Value - Android User Interface

Android examples for User Interface:EditText

Description

get EditText Value

Demo Code

/* Copyright 2014 ESRI/*from ww w.  ja  v  a 2  s . c om*/
 *
 * All rights reserved under the copyright laws of the United States
 * and applicable international laws, treaties, and conventions.
 *
 * You may freely redistribute and use this sample code, with or
 * without modification, provided you include the original copyright
 * notice and use restrictions.
 *
 * See the Sample code usage restrictions document for further information.
 *
 */
//package com.java2s;

import android.widget.EditText;

public class Main {
    public final static double DEFAULT_DOUBLE_VALUE = Double.NEGATIVE_INFINITY;

    public static double getEditTextValue(EditText text) {
        double ret = DEFAULT_DOUBLE_VALUE;

        String textString = text.getText().toString();
        if (textString != null && textString.length() > 0) {
            ret = Double.parseDouble(textString);
        }

        return ret;
    }
}

Related Tutorials