check For Bullet in SpannableString - Android Graphics

Android examples for Graphics:Spannable

Description

check For Bullet in SpannableString

Demo Code


//package com.java2s;

import android.text.SpannableString;

import android.text.style.BulletSpan;

public class Main {
    public static SpannableString checkForBullet(CharSequence s) {
        SpannableString ss;//  ww  w  . ja  v a 2 s  .c om
        // if the first element of the string is a '-' it means
        // it should be displayed as a bullet. we then remove the
        // '-' from the list and trim the spaces
        s = ((String) s).trim();
        if (s.length() > 0 && s.charAt(0) == '-') {
            s = ((String) s.subSequence(1, s.length())).trim();
            ss = new SpannableString(s + "\n");
            ss.setSpan(new BulletSpan(15), 0, s.length(), 0);
        } else {
            ss = new SpannableString(s + "\n");
        }
        return ss;
    }
}

Related Tutorials