Java Code Examples for android.widget.TextView#length()
The following examples show how to use
android.widget.TextView#length() .
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: CommentsAdapter.java From mentions with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Highlights all the {@link Mentionable}s in the test {@link Comment}. */ private void highlightMentions(final TextView commentTextView, final List<Mentionable> mentions) { if(commentTextView != null && mentions != null && !mentions.isEmpty()) { final Spannable spannable = new SpannableString(commentTextView.getText()); for (Mentionable mention: mentions) { if (mention != null) { final int start = mention.getMentionOffset(); final int end = start + mention.getMentionLength(); if (commentTextView.length() >= end) { spannable.setSpan(new ForegroundColorSpan(orange), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); commentTextView.setText(spannable, TextView.BufferType.SPANNABLE); } else { //Something went wrong. The expected text that we're trying to highlight does not // match the actual text at that position. Log.w("Mentions Sample", "Mention lost. [" + mention + "]"); } } } } }
Example 2
Source File: OverlayServiceCommon.java From heads-up with GNU General Public License v3.0 | 6 votes |
private boolean expand() { if (!isCompact) return false; else { TextView subtitle = (TextView) layout.findViewById(R.id.notification_subtitle); if ( (subtitle.getLineCount() <= MIN_LINES && subtitle.length() < 80) && !isActionButtons) { return false; } isCompact = false; subtitle.setMaxLines(MAX_LINES); if (isActionButtons) themeClass.showActionButtons(layout, -1); if (displayTime < MAX_DISPLAY_TIME) { handler.removeCallbacks(closeTimer); handler.postDelayed(closeTimer, displayTime); } return true; } }
Example 3
Source File: MaxLengthRule.java From data-binding-validator with Apache License 2.0 | 4 votes |
@Override public boolean isValid(TextView view) { return view.length() <= value; }
Example 4
Source File: MinLengthRule.java From data-binding-validator with Apache License 2.0 | 4 votes |
@Override public boolean isValid(TextView view) { return view.length() >= value; }
Example 5
Source File: ValidationLength.java From MagicForm with Apache License 2.0 | 4 votes |
@Override public boolean isValid(TextView view) { return (mMin == null || mMin <= view.length()) && (mMax == null || mMax >= view.length()); }