TextView getError - 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 getError method.

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
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
This code example shows how to use the following methods:getError
	 */ 
	@MediumTest 
	public void test_zeroAmountDollarsValidName_shouldNotAllowIt() { 
		// Enter in UI text: 0 amount should fail 
		solo.typeText(amountField, "0");
		solo.typeText(nameField, "Budget with 0 Amount");
		solo.clickOnButton("Add");
		solo.sleep(500);
 
		// We should have an error on amount where you must have a positive 
		// amount 
		String expectedError = "Amount must be greater than $0";
		String foundError = (String) amountField.getError();
 
		assertNotNull("There was no error on the amount field", foundError);
		assertEquals(expectedError, foundError);
 
		// There should be no error on nameField 
		assertNull(nameField.getError());
	} 

4
CodeRank
This code example shows how to use the following methods:getError
 
	@MediumTest 
	public void test_attemptLogin_emptyEmailThrowsError() { 
		// Set up a case with a missing email and a valid password. 
		// Should only have an error on the email field. 
		solo.typeText(passwordView, VALID_PASSWORD);
		solo.clickOnButton(0);
 
		String expectedError = "This field is required";
		String foundError = (String) emailView.getError();
 
		assertNotNull("There was no error on the email view", foundError);
		assertEquals(expectedError, foundError);
 
		// Only the email view should throw an error 
		assertNull(passwordView.getError());
	} 
 
	@MediumTest 
	public void test_attemptLogin_spaceInEmailThrowsError() { 
		// Set up a case with a badly formatted email and a good password. 
4
CodeRank
getError Method Overview
Returns the error message that was set to be displayed with setError(CharSequence), or null if no error was set or if it the error was cleared by the widget after user input.
See Code Examples for other Android TextView Methods: