2017-06-22 44 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>