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

The following examples show how to use android.widget.TextView#getError() . 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 check out the related API usage on the sidebar.
Example 1
Source File: HumanReadables.java    From android-test with 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
Source File: RobotiumUtils.java    From AndroidRipper with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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();		
}