TextView setError - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView setError method.

This code example shows how to use the following methods:getText, setError
 
  /* 
   * Return key entered by user, replacing visually similar characters 1 and 0. 
   */ 
  private String getEnteredKey() {
    String enteredKey = mKeyEntryField.getText().toString();
    return enteredKey.replace('1', 'I').replace('0', 'O');
  } 
 
  /* 
   * Verify that the input field contains a valid base32 string, 
   * and meets minimum key requirements. 
   */ 
  private boolean validateKeyAndUpdateStatus(boolean submitting) {
    String userEnteredKey = getEnteredKey();
    try { 
      byte[] decoded = Base32String.decode(userEnteredKey);
      if (decoded.length < MIN_KEY_BYTES) {
        // If the user is trying to submit a key that's too short, then 
        // display a message saying it's too short. 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:requestFocus, getText, setError
package br.com.suelengc.calctributospj.view.controller; 
 
import android.widget.EditText; 
 
public class Validator { 
 
	public boolean ValidaEditText(EditText editText) {
		boolean retorno = true;
		 
		if (editText.getText().toString().equals("")) 
		{ 
			editText.setError("Campo obrigat�rio.");
			editText.requestFocus();
			retorno = false;
		}	 
		 
		return retorno;
	} 
} 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getError, setError
			public void afterTextChanged(Editable s) {}
	    @Override 
			public void beforeTextChanged(CharSequence s, int start, int count, int after){}
	    @Override 
			public void onTextChanged(CharSequence s, int start, int before, int count){
	        if(s != null && s.length() > 0 && editText.getError() != null) {
	            editText.setError(null);
	        } 
	    } 
		}); 
 
		if (savedInstanceState != null && savedInstanceState.containsKey(PARAM_INPUT)) {
			editText.setText(savedInstanceState.getCharSequence(PARAM_INPUT));
			errorMessage = savedInstanceState.getCharSequence(PARAM_ERROR_MESSAGE);
		} 
 
		// move caret on a last position 
		editText.setSelection(editText.getText().length());
 
		return new AlertDialog.Builder(context)
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:delete, getSelectionEnd, getSelectionStart, getOffsetAfter
                             KeyEvent event) {
        int selStart, selEnd;
        boolean result = true;
 
        { 
            int a = Selection.getSelectionStart(content);
            int b = Selection.getSelectionEnd(content);
 
            selStart = Math.min(a, b);
            selEnd = Math.max(a, b);
        } 
 
        if (selStart != selEnd) {
            content.delete(selStart, selEnd);
        } else { 
            int to = TextUtils.getOffsetAfter(content, selEnd);
 
            if (to != selEnd) {
                content.delete(Math.min(to, selEnd), Math.max(to, selEnd));
            } 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getError, setError
        public ErrorPopupRemoverTextWatcher(EditText editText) {
            this.editText = editText;
        } 
 
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s != null && s.length() > 0 && editText.getError() != null) {
                editText.setError(null);
            } 
        } 
 
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        } 
 
        public void afterTextChanged(Editable s) {
        } 
    }; 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:replace, substring, markAsReplaced
    protected void replaceText(CharSequence text) {
        clearComposingText();
        int end = getSelectionEnd();
        int start = mTokenizer.findTokenStart(getText(), end);
        Editable editable = getText();
        String original = TextUtils.substring(editable, start, end);
        QwertyKeyListener.markAsReplaced(editable, start, end, original);
        editable.replace(start, end, mTokenizer.terminateToken(text));
    } 
 
    public void setTokenizer(Tokenizer t) {
        mTokenizer = t;
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ellipsize
  }   
  private String getRightDisplayString(String real, float width){  
      if(TextUtils.isEmpty(real)){  
          return "";   
      }   
      return TextUtils.ellipsize(real, new TextPaint(), width,   
              TextUtils.TruncateAt.valueOf("MIDDLE")).toString();  
  }   
     
  private float getAvail(){   
      return ELLIPSIZE_COEFFICIENT * mRect.width()/getTextSize();  
  }   
  private class MyShape extends Shape{  
 
      @Override   
      public void draw(Canvas canvas, Paint paint) {  
          paint.setColor(mColor);  
          if(mRect == null){  
              mRect = new RectF();  
          }   
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setError, setText
     *          3: Password is not valid. 
     * 
     */ 
    private void verifyPasswordError(int errorType) {
        mPasswordEditText.setText("");
        mVerifyPasswordEditText.setText("");
        switch (errorType) {
        case 1: 
            mVerifyPasswordEditText.setError("This field cannot be left blank.");
            break; 
        case 2: 
            mVerifyPasswordEditText.setError("The passwords you entered do not match.");
            break; 
        case 3: 
            mVerifyPasswordEditText.setError("Your password must contain at least:" +
                                             "\n • 1 letter." + 
                                             "\n • 6 characters." + 
                                             "\n • 5 alphanumeric characters" + 
                                             "\n • 2 characters of different types"); 
            break; 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setError
 
	public long addNewEmail(String address, EditText newEmail) {
		if (address.contains("@") && address.contains(".")) {
			return emailAdapter.insertEmailAddress(address);
		} else 
			newEmail.setError("Add a valid email");
		return -1; 
	} 
 
	/** 
	 * modify an existing email 
	 *  
	 * @param oldAddress 
	 *            the address to be modified 
	 * @param newAddress 
	 *            the new address to be added instead of the oldAddress 
	 */ 
 
	public void modifyEmail(String oldAddress, String newAddress) {
		emailAdapter.updateBin(oldAddress, newAddress);
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related TextView setError Questions & Answers:

setError Method Overview
Sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed in a popup when the TextView has focus.
See Code Examples for other Android TextView Methods: