Android SetBackground颜色不起作用

时间:2017-06-22 22:35:52

标签: java android colors

android setBackgroundColor()一直在崩溃我的应用

 View vyoo = (View) v.getParent();
 Button h = (Button) v.findViewById(R.id.hateButton);
 Button r = (Button) v.findViewById(R.id.rateButton);
 h.setBackgroundColor(Color.parseColor("#FF70AA"));

我已经尝试过了

h.setText("hello");

然而这有效

1 个答案:

答案 0 :(得分:0)

尝试getResources()。getColor(R.color.colorname); 还要在ur values / colors.xml文件中定义颜色,如下所示

memset