by Anonymous » 22 Mar 2025, 03:00
private void createStringEndingInRedColor(TextView tv, String word1, String word2) {
Spannable word = new SpannableString(word1);
tv.setText(word);
Spannable wordTwo = new SpannableString(word2);
wordTwo.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(Color.RED)), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.append(wordTwo);
}
< /code>
Ich versuche, einen Unit -Test (mit Robolectric) für das TextView -Fernseher zu schreiben, um sicherzustellen, dass Wordtwo farbe. Ich habe jedoch nur einen Verweis auf TextView TV. Wie geht man zu einer solchen Aufgabe?
private void createStringEndingInRedColor(TextView tv, String word1, String word2) {
Spannable word = new SpannableString(word1);
tv.setText(word);
Spannable wordTwo = new SpannableString(word2);
wordTwo.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(Color.RED)), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.append(wordTwo);
}
< /code>
Ich versuche, einen Unit -Test (mit Robolectric) für das TextView -Fernseher zu schreiben, um sicherzustellen, dass Wordtwo farbe. Ich habe jedoch nur einen Verweis auf TextView TV. Wie geht man zu einer solchen Aufgabe?