我想知道我是否允许用户在列表视图中执行此操作(或TextView中的缺陷):
提前致谢。
答案 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);
}
}