如何让用户在listview或textview中进行高亮,下划线或绘图等注释?

时间:2015-03-12 04:20:54

标签: android listview draw highlighting underline

我想知道我是否允许用户在列表视图中执行此操作(或TextView中的缺陷): enter image description here

提前致谢。

1 个答案:

答案 0 :(得分:0)

itemValue = "Your Hilighted Text";
if (itemValue != null) {
    int startPos = itemValue.toLowerCase(Locale.US).indexOf(getTextToFilter().toLowerCase(Locale.US));
    int endPos = startPos + getTextToFilter().length();
    if (startPos != -1) {
        Spannable spannable = new SpannableString(itemValue);
        ColorStateList blueColor = new ColorStateList(new int[][] { new int[] {}}, new int[] { Color.parseColor("#14A4D8") });
        TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, blueColor, null);
        spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        tvHilight.setText(spannable);
    } else
        tvHilight.setText(itemValue);
    }
}