i have already seen many posts and many different ways to swtich between two different drawables but I always got ResourcesNotFoundException on this little piece of code :
Drawable btn;
if (sens.getAlarmCount() == 0)
btn = view.getResources().getDrawable(R.drawable.chart_alarm_none);
else
btn = view.getResources().getDrawable(R.drawable.chart_alarm);
alarm.setBackgroundDrawable(btn);
alarm.setText(sens.getAlarmCount());
and my 2 drawbles xml files into drawable/ folder are same except gradient for alarmState:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
<corners android:bottomRightRadius="2dip"
android:bottomLeftRadius="2dip"
android:topRightRadius="2dip"
android:topLeftRadius="2dip"/>
</shape>
</item>
<item android:left="2dp" android:right="2dp" android:top="2dp" android:bottom="2dp">
<shape android:shape="rectangle">
<gradient
android:startColor="#FF0000"
android:endColor="#801818"
android:angle="225" />
</shape>
</item>
</layer-list>
Could someone help me and tell me what is wrong in there? Thanks to all of you guys
Thanks to Ameer, after i changed my Activity reference, i tried to setText with integer, basic error. Works perfectly thanks