私のボタンにcolor.xml
ファイルを使用しますが、このエラーとアプリケーションのクラッシュが表示されます。それは、color.xml
ファイルを見つけることができないと言います。ここでandroid.view.InflateException:バイナリXMLファイル行#158:クラスを膨張させるエラー
Caused by: android.content.res.Resources$NotFoundException: File res/color/color.xml from drawable resource ID #0x7f0e00dd
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3783)
at android.content.res.Resources.loadDrawable(Resources.java:3651)
at android.content.res.TypedArray.getDrawable(TypedArray.java:762)
at android.view.View.<init>(View.java:3983)
at android.widget.TextView.<init>(TextView.java:1021)
at android.widget.Button.<init>(Button.java:115)
at android.widget.Button.<init>(Button.java:108)
at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:62)
at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:5
私のボタンxmlです:
<Button
android:id="@+id/btn_buy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@color/color"
android:textColor="@color/mdtp_white"
android:text="@string/buy"/>
これは私のcolor.xmlです:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/grey" />
<item android:color="@color/myRedColor"/>
</selector>
を '@色/ buy'が何であるかを描画可能 – Pavya
にセレクタファイルを追加します。次に、以下のような
color.xml
を更新しますか?単純にカラーコードまたはXMLファイルですか? –color.xmlファイルをフォルダドロワブルに追加することを意味しますか?私はそれを試しても、同じエラーが表示されます。 –