Resource cannot be found, No identifier for missing item

后端 未结 3 1480
轮回少年
轮回少年 2020-12-19 15:20

I looked at this question however, it did not help solve my problem:

  • Resources$NotFoundException: Resource is not a Drawable

I\'m using ActionBa

相关标签:
3条回答
  • 2020-12-19 15:23

    The problem was that the compiler did not tell me that I was using items that were not part of the compatiabiliy and were not avaliable in 2.3.3

    Look at the lines I had to remove:

    drawer_list_item.xml

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceListItemSmall" <-Removed
        android:gravity="center_vertical"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:textColor="#fff"
        android:background="?android:attr/activatedBackgroundIndicator" <-Removed
        android:minHeight="?android:attr/listPreferredItemHeightSmall"/> <-Removed
    
    0 讨论(0)
  • 2020-12-19 15:37

    This is often occur due to unavailability of a drawable resource in res folder. Some times you just copy the drawable from other directory to you project's drawable folder, but forget to add this drawable from IDE's project explorer.

    0 讨论(0)
  • 2020-12-19 15:48

    To support lower versions, instead of removing the following three parameters,

      android:textAppearance="?android:attr/textAppearanceListItemSmall" 
      android:background="?android:attr/activatedBackgroundIndicator"
      android:minHeight="?android:attr/listPreferredItemHeightSmall"
    

    You can actually replace them with equivalent values/resources.

    The equivalent values can be obtained from https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml

    Now,

    • a) android:textAppearance="@android:style/TextAppearance.Medium"

    • b)

      1. Download a selector from https://github.com/habzy/Test0011_DialerPad/blob/master/res/drawable/list_item_activated_background.xml

      2. In the above project browse the resources in hdpi,mdpi etc and get files named list_activated_holo.9.png

      3. Finally

      android:background="@drawable/activated_background_holo_dark"

    • c) From the equivalent values obtained , we know that listPreferredItemHeightSmall is 48dip

      android:minHeight="48dip"

    0 讨论(0)
提交回复
热议问题