Example usage for android.widget EditText getText

List of usage examples for android.widget EditText getText

Introduction

In this page you can find the example usage for android.widget EditText getText.

Prototype

@Override
    public Editable getText() 

Source Link

Usage

From source file:Main.java

public static String getCountryCode(EditText dialCode) {
    if (dialCode != null) {
        String code = dialCode.getText().toString();
        if (code != null && code.startsWith("+")) {
            code = code.substring(1);/* www.  ja v  a  2  s . c o  m*/
        }
        return code;
    }
    return null;
}

From source file:Main.java

public static boolean isNotNull(EditText txt) {
    if (txt == null) {
        return false;
    }/*ww  w  . ja v a  2 s. co m*/

    String v = txt.getText().toString().trim();
    return !TextUtils.isEmpty(v);

}

From source file:Main.java

public static boolean isDeletePng(EditText input, int cursor) {
    String st = "[p/_000.png]";
    String content = input.getText().toString().substring(0, cursor);
    if (content.length() >= st.length()) {
        String checkStr = content.substring(content.length() - st.length(), content.length());
        String regex = "\\[[^\\]]+\\]";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(checkStr);
        return m.matches();
    }/* ww  w .ja  va 2s . c o  m*/
    return false;
}

From source file:Main.java

public static boolean checkPswdLen(EditText editText) {
    if (editText == null) {
        return false;
    }/*from  www  . j a  va2s  . c  om*/
    int len = editText.getText().toString().trim().length();
    return len >= 6 && len <= 20;
}

From source file:Main.java

public static int getOdometerInt(EditText text) {
    int value = 0;
    try {// ww w . j a va  2 s .  c om
        value = Integer.valueOf(text.getText().toString().trim());
    } catch (NumberFormatException e) {
    }
    return value;
}

From source file:Main.java

public static String getText(Activity activity, int resourceId) {
    String result = null;/*  w w w  .j av a  2s .  com*/
    EditText et = (EditText) activity.findViewById(resourceId);
    if (et != null) {
        result = et.getText().toString();
    }
    return result;
}

From source file:Main.java

public static void setCursorAtTheEnd(EditText editText) {
    try {//from w  ww  .  ja va2 s . c o  m
        if (editText != null) {
            editText.setSelection(editText.getText().length());
        }
    } catch (Exception ex) {
    }
}

From source file:Main.java

/**
 * Gets a String from an edit text. It also trims off any leading or ending white space
 * @param et//from w  ww .  ja v  a2 s .  com
 * @return
 */
public static String getFromEditText(EditText et) {
    if (et == null) {
        return null;
    }

    String str = et.getText().toString();
    if (!str.equals(null)) {
        str = str.trim();
        return str;
    }
    return str;
}

From source file:Main.java

public static boolean isEquals(EditText paramEditText1, EditText paramEditText2) {
    if ((paramEditText1 == null) || (paramEditText2 == null))
        ;//from w w  w.ja  v a2s.com
    while (!paramEditText1.getText().toString().equals(paramEditText2.getText().toString()))
        return false;
    return true;
}

From source file:Main.java

public static String getEditTextValue(EditText editText) {
    String result = "";
    if (editText == null)
        return result;

    Editable editable = editText.getText();
    if (editable == null)
        return result;

    result = editable.toString();/*www  .j  av  a  2 s.  c  om*/
    if (result == null)
        result = "";
    return result.trim();
}