Java Code Examples for android.widget.TextView#getError()

The following examples show how to use android.widget.TextView#getError() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: android-test   File: HumanReadables.java    License: Apache License 2.0 6 votes vote down vote up
private static void innerDescribe(TextView textBox, ToStringHelper helper) {
  if (null != textBox.getText()) {
    helper.add("text", textBox.getText());
  }

  if (null != textBox.getError()) {
    helper.add("error-text", textBox.getError());
  }

  if (null != textBox.getHint()) {
    helper.add("hint", textBox.getHint());
  }

  helper.add("input-type", textBox.getInputType());
  helper.add("ime-target", textBox.isInputMethodTarget());
  helper.add("has-links", textBox.getUrls().length > 0);
}
 
Example 2
/**
 * Checks if a View matches a certain string and returns the amount of total matches.
 * 
 * @param regex the regex to match
 * @param view the view to check
 * @param uniqueTextViews set of views that have matched
 * @return number of total matches
 */

public static int getNumberOfMatches(String regex, TextView view, Set<TextView> uniqueTextViews){
	if(view == null) {
		return uniqueTextViews.size();
	}
	
	Pattern pattern = null;
	try{
		pattern = Pattern.compile(regex);
	}catch(PatternSyntaxException e){
		pattern = Pattern.compile(regex, Pattern.LITERAL);
	}
	
	Matcher matcher = pattern.matcher(view.getText().toString());
	
	if (matcher.find()){
		uniqueTextViews.add(view);
	}
	
	if (view.getError() != null){
		matcher = pattern.matcher(view.getError().toString());
		if (matcher.find()){
			uniqueTextViews.add(view);
		}
	}	
	if (view.getText().toString().equals("") && view.getHint() != null){
		matcher = pattern.matcher(view.getHint().toString());
		if (matcher.find()){
			uniqueTextViews.add(view);
		}
	}	
	return uniqueTextViews.size();		
}