So erhalten Sie von Textview und seiner Farbe, um einen Unit -Test zu schreiben

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: So erhalten Sie von Textview und seiner Farbe, um einen Unit -Test zu schreiben

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?

Top