【发布时间】:2014-10-02 07:59:43
【问题描述】:
大家好,我正在尝试获取 TextView 的背景颜色,但找不到。
我正在使用 robotsium 对我的聊天应用进行健全性自动化测试。
主要目标是找到天气文本视图气泡颜色为灰色或蓝色并进行断言。
ArrayList<TextView> textViewList = solo.getCurrentViews(TextView.class);
for (TextView textview : textViewList )
{
if (textview != null && textview.isShown())
{
if(textview.getText().toString().equals(Message))
{
ColorDrawable drawable = (ColorDrawable)textview.getBackground();
int color= drawable.getColor();
//doing some assertion
}
}
}
这就是我想要获得颜色但有异常的原因
java.lang.ClassCastException: android.graphics.drawable.LayerDrawable cannot be cast to
android.graphics.drawable.ColorDrawable
请帮助我,谢谢 :)
【问题讨论】:
-
为什么不使用两条短信(发送和接收)并为它们断言
标签: java android css junit robotium