Here you can find the source of getNumber(TextView view)
Parameter | Description |
---|---|
view | - the view to read from |
public static Integer getNumber(TextView view)
//package com.java2s; import android.widget.TextView; public class Main { /**/*w w w. j a v a 2 s.co m*/ * extract an Integer out of a TextView * * @param view - the view to read from * @return the Integer value or NULL in case of a non-parseable String */ public static Integer getNumber(TextView view) { Integer result; if (!isEmpty(view)) { try { result = Integer.parseInt(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(); } }