2017-06-22 45 views
-2

的Android setBackgroundColor()不断崩溃我的应用程序的Android的setBackground颜色不工作

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"); 

但是这个工作

+0

崩溃日志或stacktrace说什么? –

回答

0

尝试getResources()。的getColor(R.color。颜色); 还定义颜色在你的价值观/ colors.xml这样的文件

<color 
     name="color_name" 
     >hex_color</color>