Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a span like this:

 private SpannableStringBuilder spandex(List<String> ret, Boolean startDark) {
    SpannableStringBuilder spanBuilder = new SpannableStringBuilder();
    Spannable span = null;
    int color = 0;
    int startDarkMod = 0;
    if(startDark)
        startDarkMod = 1;
    for (String x : ret) {

        if ((ret.indexOf(x) + startDarkMod) % 2 > 0)
            color = WzTheme.NOT_HIGHLIGHTED_COLOR;
        else
            color = WzTheme.ALT_NOT_HIGHLIGHTED_COLOR;

        span = new SpannableString(x.toUpperCase());
        span.setSpan(new ForegroundColorSpan(color),
                0,
                x.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        spanBuilder.append(span);
    }

    return spanBuilder;
}


public static int NOT_HIGHLIGHTED_COLOR = Color.rgb(68, 68, 68);
public static int ALT_NOT_HIGHLIGHTED_COLOR = Color.rgb(110, 110, 110);

It produces light gray and dark grey code like this: screen shot galaxy5 activity

Then there is that bright white "T". It happens after every ? character, which, as the other thread mentioned, gets converted to SS when capitalized. I would prefer no capatalization of that char, but I can live with the conversion to SS. What I need to stop from happening is the big white "T". Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
240 views
Welcome To Ask or Share your Answers For Others

1 Answer

ugh, this fixes it:

private String myUpperCase(String word) {
    word = word.replaceAll("?", "XXX");
    return word.toUpperCase().replaceAll("XXX", "?");
}  

so as you probably already know, the issue is that ? gets expanded to SS in java utf-8 toUpperCase() and that increases the length of the string in the span by one, but "x" (in my code above) is one char short (length) so i get the default white text.

i am happy with the fix.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...