Android Open Source - OpenCmsMobile-AndroidApp Styleable Spannable String Builder






From Project

Back to project page OpenCmsMobile-AndroidApp.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project OpenCmsMobile-AndroidApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package cz.nelasoft.opencms.mobile;
//from  ww w.j  a v  a2s .c  om
import android.graphics.Typeface;
import android.text.SpannableStringBuilder;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;

public class StyleableSpannableStringBuilder extends SpannableStringBuilder {

  public StyleableSpannableStringBuilder appendWithStyle(CharSequence text, CharacterStyle... c) {
    super.append(text);
    int startPos = length() - text.length();
    for (CharacterStyle cs : c) {
      setSpan(cs, startPos, length(), 0);
    }
    return this;
  }

  public StyleableSpannableStringBuilder appendBold(CharSequence text) {
    return appendWithStyle(text, new StyleSpan(Typeface.BOLD));
  }

  public StyleableSpannableStringBuilder appendColor(CharSequence text, int color) {
    return appendWithStyle(text, new ForegroundColorSpan(color));
  }

  public StyleableSpannableStringBuilder appendColorBold(CharSequence text, int color) {
    return appendWithStyle(text, new StyleSpan(Typeface.BOLD), new ForegroundColorSpan(color));
  }

}




Java Source Code List

cz.nelasoft.opencms.mobile.Config.java
cz.nelasoft.opencms.mobile.ContactsFragment.java
cz.nelasoft.opencms.mobile.DownloadManager.java
cz.nelasoft.opencms.mobile.EventAdapter.java
cz.nelasoft.opencms.mobile.EventDetailActivity.java
cz.nelasoft.opencms.mobile.EventFragment.java
cz.nelasoft.opencms.mobile.Event.java
cz.nelasoft.opencms.mobile.FileCache.java
cz.nelasoft.opencms.mobile.IRefreshFragment.java
cz.nelasoft.opencms.mobile.ImageLoader.java
cz.nelasoft.opencms.mobile.MainActivity.java
cz.nelasoft.opencms.mobile.MemoryCache.java
cz.nelasoft.opencms.mobile.NewsAdapter.java
cz.nelasoft.opencms.mobile.NewsDetailActivity.java
cz.nelasoft.opencms.mobile.NewsFragment.java
cz.nelasoft.opencms.mobile.News.java
cz.nelasoft.opencms.mobile.SplashActivity.java
cz.nelasoft.opencms.mobile.StyleableSpannableStringBuilder.java
cz.nelasoft.opencms.mobile.WebContentFragment.java