I get the Text from the internet and put the data in a "FeedItem"-class. Now, I want to check the text whether it contains a "@". So, here is my code so far:
        // Check for empty status message
        if (!TextUtils.isEmpty(item.getStatus())) {
            if (item.getStatus().contains("@")) {
                String[] splited = item.getStatus().toString().split("\\s+");
                Spannable word = new SpannableString(item.getStatus());
                for (int i = 0; i < splited.length; i++) {
                    if (splited[i].toString().contains("@")) {
                        SpannableString s = SpannableString.valueOf(splited[i].toString());
                        s.setSpan(new ForegroundColorSpan(Color.BLUE), 0, word.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    }
                }
                statusMsg.setText(word);
            } else {
                statusMsg.setTextColor(R.color.black);
                statusMsg.setText(item.getStatus());
            }
            statusMsg.setVisibility(View.VISIBLE);
I worked with SpannableString and Html.fromHtml but it didn't work for me. The for loop gives me each word from the String. Now if one word contains the "@" i want to colorize only this word. Thanks.
 
    