I have a problem when I get this error ...
03-02 19: 59: 03.539: E / AndroidRuntime (11177): java.lang.RuntimeException: Cannot start activity ComponentInfo {com.comp4020.kitchenaid / com.kitchenaid.MainActivity}: android.content.res.Resources $ NotFoundException: File res / drawable / main_button.xml from resource resource ID # 0x7f020003
I do not know why this is happening. A resource most definitely exists, and it is correctly named without errors. The only thing I think about is that I added characters to the program that were not installed by default, so he asked "Change to UTF-8," and I said yes.
I assign this resource as follows:
ingButton.setBackgroundResource(R.drawable.main_button);
nextButton.setBackgroundResource(R.drawable.main_button);
prevButton.setBackgroundResource(R.drawable.main_button);
timerButton.setBackgroundResource(R.drawable.main_button);
I also tried a cleaning project. I have no idea what is going on.
EDIT: Here is a tapped
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_pressed="true"
android:background="@drawable/gradient_pressed"
/>
<item android:background="@drawable/gradient"/>
</selector>
gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient android:startColor="@color/gradientDark"
android:centerColor="@color/gradientDark"
android:endColor="@color/gradientLight"
android:angle="90" />
</shape>
gradient_pressed.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient android:startColor="@color/highlightGradientDark"
android:centerColor="@color/highlightGradientDark"
android:endColor="@color/highlightGradientLight"
android:angle="90" />
</shape>
source
share