List of usage examples for android.widget TextView getHint
@ViewDebug.CapturedViewProperty
public CharSequence getHint()
From source file:Main.java
public static String getHint(TextView textView) { if (textView != null) { return textView.getHint().toString(); } else {// www . j a va 2 s . c o m return ""; } }
From source file:Main.java
/** * Checks if a View matches a certain string and returns the amount of total matches. * //ww w . jav a 2 s .com * @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(); }
From source file:com.example.mysteryhunt.UserActivity.java
private void showAttributes() { final UserAttributesAdapter attributesAdapter = new UserAttributesAdapter(getApplicationContext()); final ListView attributesListView; attributesListView = (ListView) findViewById(R.id.listViewUserAttributes); attributesListView.setAdapter(attributesAdapter); attributesList = attributesListView; attributesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w . j a va 2s .co m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView data = (TextView) view.findViewById(R.id.editTextUserDetailInput); String attributeType = data.getHint().toString(); String attributeValue = data.getText().toString(); showUserDetail(attributeType, attributeValue); } }); }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java
ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, View fromView) { // Bookkeeping this.id = id; this.parentId = (parent != null) ? parent.getId() : null; // API 16+ properties this.scrollable = AT_16 ? fromView.isScrollContainer() : null; // API 11+ properties this.backgroundDrawableColor = (AT_11 && (fromView != null) && (fromView.getBackground() instanceof ColorDrawable)) ? ((ColorDrawable) fromView.getBackground()).getColor() : null;/*from ww w .ja va 2s . com*/ // Base properties this.visibleToUser = ViewAccessibilityUtils.isVisibleToUser(fromView); this.className = fromView.getClass().getName(); this.accessibilityClassName = null; this.packageName = fromView.getContext().getPackageName(); this.resourceName = (fromView.getId() != View.NO_ID) ? ViewAccessibilityUtils.getResourceNameForView(fromView) : null; this.contentDescription = SpannableString.valueOf(fromView.getContentDescription()); this.enabled = fromView.isEnabled(); if (fromView instanceof TextView) { TextView textView = (TextView) fromView; // Hint text takes precedence if no text is present. CharSequence text = textView.getText(); if (TextUtils.isEmpty(text)) { text = textView.getHint(); } this.text = SpannableString.valueOf(text); this.textSize = textView.getTextSize(); this.textColor = textView.getCurrentTextColor(); this.typefaceStyle = (textView.getTypeface() != null) ? textView.getTypeface().getStyle() : null; } else { this.text = null; this.textSize = null; this.textColor = null; this.typefaceStyle = null; } this.importantForAccessibility = ViewAccessibilityUtils.isImportantForAccessibility(fromView); this.clickable = fromView.isClickable(); this.longClickable = fromView.isLongClickable(); this.focusable = fromView.isFocusable(); this.editable = ViewAccessibilityUtils.isViewEditable(fromView); this.canScrollForward = (ViewCompat.canScrollVertically(fromView, 1) || ViewCompat.canScrollHorizontally(fromView, 1)); this.canScrollBackward = (ViewCompat.canScrollVertically(fromView, -1) || ViewCompat.canScrollHorizontally(fromView, -1)); this.checkable = (fromView instanceof Checkable); this.checked = (fromView instanceof Checkable) ? ((Checkable) fromView).isChecked() : null; this.hasTouchDelegate = (fromView.getTouchDelegate() != null); // There may be subtle differences between the bounds from a View instance compared to that of // its AccessibilityNodeInfo. The latter uses a @hide getBoundsOnScreen method, which clips to // parent bounds. android.graphics.Rect tempRect = new android.graphics.Rect(); if (fromView.getGlobalVisibleRect(tempRect)) { this.boundsInScreen = new Rect(tempRect); } else { this.boundsInScreen = null; } this.nonclippedHeight = fromView.getHeight(); this.nonclippedWidth = fromView.getWidth(); }