I am trying to make an app that summarizes text, and passes that text into a string. From here I split the string word by word, and search for particular words. Ideally, I would like particular words to be capitalized and colored red. However, all of the tutorials I find show how to change the color of the String as a whole. Here is my code:
public void convertToNotes() {
String conversionText;
TextView verifyTextView;
classNotes=(EditText)findViewById(R.id.class_notes);
className=(EditText)findViewById(R.id.class_name);
verifyTextView = (TextView) findViewById(R.id.textView);
verifyTextView.setSingleLine(false);
conversionText = classNotes.getText().toString();
String[] result = conversionText.split("//n");
String important = "<font color=#00aeef>"+"IMPORTANT" + "</font>";
important.toUpperCase();
// tried to load premade textview w/ styling. Threw null pointer exception important_replace = (TextView)findViewById(R.id.important_replacement);
//String important_detected = important_replace.toString();
for (int a = 0; a < result.length; a++) {
// You may want to check for a non-word character before blindly
// performing a replacement
// It may also be necessary to adjust the character class
result[a] = result[a].replaceAll("sorry", "");
result[a] = result[a].replaceAll("uh", "");
result[a] = result[a].replaceAll("um", "");
result[a] = result[a].replaceAll("haha", "");
result[a] = result[a].replaceAll("nevermind", "");
result[a] = result[a].replaceAll("important", " \n" + Html.fromHtml(important));
verifyTextView.setText(Arrays.toString(result));
}
}
The capitalization words perfectly, however the textColor is still Black.