android InflateException /?attr/selectableItemBackground

时间:2015-07-28 16:27:05

标签: android android-recyclerview attr

59 line of my xml file:

  <ImageView
        android:id="@+id/imageViewDrawerBadge"
        android:layout_width="72dp"
        android:layout_height="72dp"
        android:background="?attr/selectableItemBackground"
        android:paddingBottom="20dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingTop="20dp"
        android:scaleType="centerCrop"
        android:src="@drawable/default_badge" />

Error happens because of ?attr/ atribute. If i replace it for #FF00000 or something else, all works fine. This crash happens not often.

07-28 19:16:46.686    9294-9294/ru.handh.android.zakazaka E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: ru.handh.android.zakazaka, PID: 9294
android.view.InflateException: Binary XML file line #59: Error inflating class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:640)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
        at 

1 个答案:

答案 0 :(得分:2)

Change to

 android:background="?android:selectableItemBackground"