Android TextView Get getDouble(TextView view)

Here you can find the source of getDouble(TextView view)

Description

extract an Double out of a TextView

Parameter

Parameter Description
view - the view to read from

Return

the Double value or NULL in case of a non-parseable String

Declaration

public static Double getDouble(TextView view) 

Method Source Code

//package com.java2s;

import android.widget.TextView;

public class Main {
    /**//from   ww w  .j av  a2s  .  co m
     * extract an Double out of a TextView
     *
     * @param view - the view to read from
     * @return the Double value or NULL in case of a non-parseable String
     */
    public static Double getDouble(TextView view) {
        Double result;
        if (!isEmpty(view)) {
            try {
                result = Double.parseDouble(getString(view));
            } catch (Exception e) {
                result = null;
            }
        } else {
            result = null;
        }
        return result;
    }

    /**
     * checks, if the passed TextView contains some text
     *
     * @param view - the TextView
     * @return true, if a non-null, non-blank string is found inside of the text view
     */
    public static boolean isEmpty(TextView view) {
        if (view != null && view.getText() != null) {
            return getString(view).length() == 0;
        }
        return false;
    }

    /**
     * extract the trimmed string value out of the passed TextView
     *
     * @param view - the view to read from
     * @return the trimmed string value from the view
     */
    public static String getString(TextView view) {
        return view.getText().toString().trim();
    }
}

Related

  1. checkTextView(TextView textView)
  2. getText(TextView textView)
  3. getText(TextView textView)
  4. getNumber(TextView view)
  5. getString(TextView view)
  6. getEditTextName( ArrayList editTextNames, ArrayList ediTextView, Context ctx)
  7. getSizeForString(String text, TextView textView)