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 boolean noSpecialCharacters(EditText editText) {
    if (nonEmpty(editText)) {
        String content = removeBlankSpace(editText.getText().toString());
        return content.matches("[a-zA-Z0-9.? ]*");
    } else {/*from   w  w w .j  a v a 2s. c o  m*/
        Log.e("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:Main.java

public static boolean validateEmail(EditText editText) {
    if (nonEmpty(editText)) {
        String emailAsString = removeBlankSpace(editText.getText().toString());
        return emailAsString.matches(EMAIL_PATTERN_1) || emailAsString.matches(EMAIL_PATTERN_2);

    } else {/*from  ww  w  .j a  v  a2  s . co m*/
        Log.d("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:Main.java

public static boolean matchMinLength(EditText editText, int length) {
    if (nonEmpty(editText)) {
        String content = removeBlankSpace(editText.getText().toString());
        return content.length() >= length ? YES : NO;
    } else {//from  w w w.j  a v  a  2s.  c om
        Log.e("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:Main.java

public static boolean matchLength(EditText editText, int length) {
    if (nonEmpty(editText)) {
        String content = removeBlankSpace(editText.getText().toString());
        return content.length() == length;
    } else {/*ww  w  .j  a  va  2  s.  c o  m*/
        Log.d("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:Main.java

public static boolean matchText(EditText baseEditText, EditText... editTexts) {
    if (nonEmpty(baseEditText)) {
        String matchString = baseEditText.getText().toString();
        for (EditText editText : editTexts) {
            if (editText == null || !(matchString.equals(editText.getText().toString()))) {
                return NO;
            }//from  w  w w. ja va2s  . c o  m
        }
    } else {
        return NO;
    }
    return YES;
}

From source file:Main.java

public static boolean isValidEmail(EditText paramEditText) {
    if (paramEditText == null) {
        throw new NullPointerException("EditText can't null");
    }//from  ww w.j av  a  2s . c  o m
    return isValidEmail(paramEditText.getText().toString());
}

From source file:Main.java

public static boolean isValidPass(EditText paramEditText) {
    if (paramEditText == null) {
        throw new NullPointerException("EditText can't null");
    }/*from   ww w . j av  a2  s . com*/
    return isValidPass(paramEditText.getText().toString());
}

From source file:Main.java

/**
 * Substitute the selection of given {@link EditText} with specified text.<br />
 * If no text is selected then specified text will be inserted at current cursor position.<br />
 * Newly inserted text will be selected.
 * @param editText Target {@link EditText}.
 * @param txt Text to insert.//from ww w . ja va 2s.  c om
 * @param select {@code true} to select newly added text.
 */
public static void setTextInsideSelection(EditText editText, String txt, boolean select) {
    Editable editable;
    int selStart;
    int selEnd;

    editable = editText.getText();

    selStart = editText.getSelectionStart();
    selEnd = editText.getSelectionEnd();
    if (selStart > selEnd) {
        int tmp = selStart;
        selStart = selEnd;
        selEnd = tmp;
    }

    editable.replace(selStart, selEnd, txt);

    if (select) {
        editText.setSelection(selStart, selStart + txt.length());
    } else {
        editText.setSelection(selStart + txt.length());
    }
}

From source file:Main.java

public static boolean isValidPhoneNumber(EditText paramEditText) {
    if (paramEditText == null) {
        throw new NullPointerException("EditText can't null");
    }//from   w  w w.  j a  v  a2s. com
    return isValidPhoneNumber(paramEditText.getText().toString());
}

From source file:Main.java

public static boolean mobileNumberValidation(EditText editText) {
    if (nonEmpty(editText)) {
        String mobileNumber = removeBlankSpace(editText.getText().toString().trim());
        return Patterns.PHONE.matcher(mobileNumber).matches();
    } else {/*from w  w  w.  jav  a 2  s  . c  om*/
        Log.d("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}