I want to write a method that will check two String for identity. The first String will contain the correct answer, and the second will be partially typed manually. Therefore, I need to, as a result, the text could be highlighted in red, but not all, but the part where there is an error.
private void testOne() { int len = 0, i = 0; String one, two, ds = ""; one = "hellow world"; two = "Qellow Qorld"; while(i < two.length()) { if (one.charAt(i) != two.charAt(i)) { ds += two.charAt(i); len = i; } else { ds += two.charAt(i); } i++; } Spannable ss = new SpannableString(ds); ss.setSpan(new ForegroundColorSpan(Color.RED), len, i, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); numberOFresponses.setText(ss); // Вывожу результат на экран. } Here's what I got.
int len // дает знать с какого символа начинать закрашивать. Perhaps you need to do this all through arrays, but I do not know how to implement it.
