【发布时间】:2014-10-28 14:58:21
【问题描述】:
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);
}
我正在尝试为 TextView 电视编写一个单元测试(使用 Robolectric),以确保 wordTwo 是 Color.RED。但是,我只有对 TextView tv 的引用。如何完成这样的任务?
【问题讨论】:
标签: android textview robolectric