Codota Logo
SpannableStringBuilder.clearSpans
Code IndexAdd Codota to your IDE (free)

How to use
clearSpans
method
in
android.text.SpannableStringBuilder

Best Java code snippets using android.text.SpannableStringBuilder.clearSpans (Showing top 15 results out of 315)

  • Common ways to obtain SpannableStringBuilder
private void myMethod () {
SpannableStringBuilder s =
  • Codota Iconnew SpannableStringBuilder()
  • Codota IconCharSequence text;new SpannableStringBuilder(text)
  • Smart code suggestions by Codota
}
origin: TommyLemon/APIJSON

/**
 * @param context
 * @param spannable
 * @param title
 * @return
 */
public static SpannableStringBuilder getText(Activity context, Spannable spannable, String title) {
  if (spannable == null || spannable.length() <= 0) {
    Log.e(TAG, "getText  spannable == null || spannable.length() <= 0 >> return new SpannableStringBuilder();");
    return new SpannableStringBuilder();
  }
  SpannableStringBuilder builder = new SpannableStringBuilder(spannable);
  builder.clearSpans();// should clear old spans
  URLSpan[] urls = spannable.getSpans(0, spannable.length(), URLSpan.class);
  if (urls != null) {
    for (URLSpan urlSpan : urls) {
      if (urlSpan != null) {
        MyURLSpan myURLSpan = new MyURLSpan(context, urlSpan.getURL(), title);
        builder.setSpan(myURLSpan, spannable.getSpanStart(urlSpan), spannable
            .getSpanEnd(urlSpan), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
      }
    }
  }
  return builder;
}
origin: allenz8512/AndroidAppLog

public void unbind() {
  textViewRef = null;
  lastUpdateMillis = 0;
  logBuilder.clearSpans();
  logBuilder.clear();
  logEventQueue.clear();
}
origin: enricocid/LaunchEnr

@Override
public void clearTypedText() {
  mDefaultKeySsb.clear();
  mDefaultKeySsb.clearSpans();
  Selection.setSelection(mDefaultKeySsb, 0);
}
origin: fookwood/Launcher3

private void clearTypedText() {
  mDefaultKeySsb.clear();
  mDefaultKeySsb.clearSpans();
  Selection.setSelection(mDefaultKeySsb, 0);
}
origin: klinker24/Android-Blur-Launcher

@Override
public void clearTypedText() {
  mDefaultKeySsb.clear();
  mDefaultKeySsb.clearSpans();
  Selection.setSelection(mDefaultKeySsb, 0);
}
origin: klinker24/launcher3

@Override
public void clearTypedText() {
  mDefaultKeySsb.clear();
  mDefaultKeySsb.clearSpans();
  Selection.setSelection(mDefaultKeySsb, 0);
}
origin: WeAreFairphone/FP2-Launcher

private void clearTypedText() {
  mDefaultKeySsb.clear();
  mDefaultKeySsb.clearSpans();
  Selection.setSelection(mDefaultKeySsb, 0);
}
origin: stackoverflow.com

String htmlLinkText = "Lorem ipsum <a href='http://www.google.com'>dolor</a> sit amet";
 testView.setText(Html.fromHtml(htmlLinkText));
 testView.setMovementMethod(LinkMovementMethod.getInstance());
 CharSequence text = testView.getText();
 if (text instanceof Spannable) {
   int end = text.length();
   Spannable sp = (Spannable) testView.getText();
   URLSpan[] urls = sp.getSpans(0, end, URLSpan.class);
   SpannableStringBuilder style = new SpannableStringBuilder(text);
   style.clearSpans();//should clear old spans
   for (URLSpan url : urls) {
     CustomerTextClick click = new CustomerTextClick(url.getURL());
     style.setSpan(click, sp.getSpanStart(url), sp.getSpanEnd(url), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   }
   testView.setText(style);
 }
origin: ymback/NGA-CLIENT-VER-OPEN-SOURCE

  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_client, null);
    TextView contentView = view.findViewById(R.id.client_device_dialog);
    String content = String.format(getString(R.string.about_client), BuildConfig.VERSION_NAME);
    contentView.setText(Html.fromHtml(content));
    contentView.setMovementMethod(LinkMovementMethod.getInstance());
    CharSequence text = contentView.getText();
    if (text instanceof Spannable) {
      int end = text.length();
      Spannable sp = (Spannable) contentView.getText();
      URLSpan[] urls = sp.getSpans(0, end, URLSpan.class);
      SpannableStringBuilder style = new SpannableStringBuilder(text);
      style.clearSpans();// should clear old spans
      for (URLSpan url : urls) {
        style.setSpan(new UrlSpan(url.getURL()), sp.getSpanStart(url), sp.getSpanEnd(url), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
      }
      contentView.setText(style);
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setView(view)
        .setTitle(R.string.about)
        .setPositiveButton(android.R.string.ok, null);
    return builder.create();
  }
}
origin: xuyisheng/TextViewForFullHtml

private void txtViewSetText(TextView view, CharSequence text, BufferType type) {
  CharSequence t = text;
  if (t instanceof Spannable) {
    int end = text.length();
    Spannable sp = (Spannable) t;
    URLSpan[] urls = sp.getSpans(0, end, URLSpan.class);
    SpannableStringBuilder style = new SpannableStringBuilder(text);
    if (urls.length > 0) {
      view.setMovementMethod(LinkMovementMethod.getInstance());
      for (URLSpan url : urls) {
        HJURLSpan myURLSpan = new HJURLSpan(view, url.getURL());
        style.clearSpans();
        style.setSpan(myURLSpan, sp.getSpanStart(url),
            sp.getSpanEnd(url),
            Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
      }
    }
    view.setText(style, type);
  }
}
origin: klinker24/launcher3

@Override
public void clearSearchResult() {
  if (mApps.setOrderedFilter(null)) {
    mAppsRecyclerView.onSearchResultsChanged();
  }
  // Clear the search query
  mSearchQueryBuilder.clear();
  mSearchQueryBuilder.clearSpans();
  Selection.setSelection(mSearchQueryBuilder, 0);
}
origin: fookwood/Launcher3

  @Override
  public void clearSearchResult() {
    mApps.setOrderedFilter(null);
    mAppsRecyclerView.onSearchResultsChanged();

    // Clear the search query
    mSearchQueryBuilder.clear();
    mSearchQueryBuilder.clearSpans();
    Selection.setSelection(mSearchQueryBuilder, 0);
  }
}
origin: enricocid/LaunchEnr

@Override
public void clearSearchResult() {
  if (mApps.setOrderedFilter(null)) {
    mAppsRecyclerView.onSearchResultsChanged();
  }
  // Clear the search query
  mSearchQueryBuilder.clear();
  mSearchQueryBuilder.clearSpans();
  Selection.setSelection(mSearchQueryBuilder, 0);
}
origin: klinker24/Android-Blur-Launcher

@Override
public void clearSearchResult() {
  if (mApps.setOrderedFilter(null)) {
    mAppsRecyclerView.onSearchResultsChanged();
  }
  // Clear the search query
  mSearchQueryBuilder.clear();
  mSearchQueryBuilder.clearSpans();
  Selection.setSelection(mSearchQueryBuilder, 0);
}
origin: allenz8512/AndroidAppLog

@Override
protected void handleEventQueue() throws InterruptedException {
  final LogEvent event = logEventQueue.poll(MIN_PRINT_PERIOD,
      TimeUnit.MILLISECONDS);
  if (textViewRef != null) {
    final TextView textView = textViewRef.get();
    if (textView != null) {
      final long currentMillis = System.currentTimeMillis();
      if (event != null) {
        final int start = logBuilder.length();
        logBuilder.append(event.toString());
        logBuilder.setSpan(new ForegroundColorSpan(event.getLevel()
            .getColor()), start, logBuilder.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        logBuilder.append("\n");
      }
      if ((currentMillis - lastUpdateMillis > MIN_PRINT_PERIOD || lastUpdateMillis == 0)
          && logBuilder.length() > 0) {
        postLogToUIThread(new SpannedString(logBuilder));
        lastUpdateMillis = currentMillis;
        logBuilder.clearSpans();
        logBuilder.clear();
      }
    }
  }
}
android.textSpannableStringBuilderclearSpans

Popular methods of SpannableStringBuilder

  • <init>
  • setSpan
  • append
  • length
  • getSpans
  • toString
  • getSpanStart
  • removeSpan
  • getSpanEnd
  • delete
  • replace
  • charAt
  • replace,
  • charAt,
  • clear,
  • subSequence,
  • getSpanFlags,
  • valueOf,
  • insert,
  • nextSpanTransition,
  • getChars

Popular in Java

  • Finding current android device location
  • requestLocationUpdates (LocationManager)
  • orElseThrow (Optional)
  • startActivity (Activity)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now