すでにフラグメントを試してみる必要があります。これがあなたを助けることを望みます。
final TextView sampleText =(TextView)findViewById(R.id.tv_sample_text);
EditText ed_texthere =(EditText)findViewById(R.id.ed_texthere);
final String fullText = sampleText.getText().toString();
ed_texthere.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
String typedText = charSequence.toString();
if (typedText != null && !typedText.isEmpty()) {
int startPos = fullText.toLowerCase(Locale.US).indexOf(typedText.toLowerCase(Locale.US));
int endPos = startPos + typedText.length();
if (startPos != -1) {
Spannable spannable = new SpannableString(fullText);
ColorStateList blueColor = new ColorStateList(new int[][]{new int[]{}}, new int[]{Color.BLUE});
TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, blueColor, null);
spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
sampleText.setText(spannable);
} else {
sampleText.setText(fullText);
}
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});