National Letter Selector Doesn't Appear
What I had to do was to implement a text input able to color letters green or red. My piece of code can do this but there is a problem. I can't write an national letter because the
Solution 1:
The InputFilter helped me resolve the problem:
InputFilter filter = new InputFilter() {
final String good_letter = "<font color='#2FEE0D'>$</font>";
final String bad_letter = "<font color='#FF0000'>$</font>";
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend)
{
String input = dest.toString().substring(0, dstart) + source.
subSequence(start, end) + dest.toString().substring(dend);
StringBuffer output = new StringBuffer();
List<Entry<Character, Boolean>> correction = Learn.this.
learn_manager.getLetters(input);
Log.d(TAG, "afterTextChanged: input size (" + input.length() +
")");
System.out.println(input);
for (int i = dstart; i < dstart + end; i++)
{
if (correction.get(i).getValue())
{
output.append(this.good_letter.replace('$', correction.
get(i).getKey()));
} else {
output.append(this.bad_letter.replace('$', correction.
get(i).getKey()));
}
}
return Html.fromHtml(output.toString());
}
};
Post a Comment for "National Letter Selector Doesn't Appear"