Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Drawer Using Appcompat v7 - Issues with ?android:attr Tag

I am using an actionbar and navigation drawer in my project. Using appcompat v7 and v4.

I have added the appcompat v7 WITH resources.

The following is my textview for the navigation drawer list taken straight from the android sample app found at Creating a Navigation Drawer

The bottom three lines all cause my application to fail, it builds okay, but I get a force close and I am not sure how to solve the problem. I don't understand why the attributes are not being found, considering I added the appcompat with its resources. Or are they not valid with the appcompat or something?

MinSDK Version is 10 and at which the code fails. Above API 10 the code works fine.

<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:gravity="center_vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:textColor="#fff"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:background="?android:attr/activatedBackgroundIndicator"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
like image 560
Reafidy Avatar asked Aug 15 '13 09:08

Reafidy


2 Answers

You can use the values as defined in the compatibility library: It specifies all except the background, which I have chosen listChoiceBackgroundIndicator, although you might play with others as well.

<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="?attr/textAppearanceListItemSmall"
    android:gravity="center_vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:textColor="#fff"
    android:background="?attr/listChoiceBackgroundIndicator"
    android:minHeight="?attr/listPreferredItemHeightSmall"/>
like image 94
PearsonArtPhoto Avatar answered Nov 14 '22 23:11

PearsonArtPhoto


I had same issue. As i understand older apis haven't predefined textAppearanceListItemSmall, activatedBackgroundIndicator and listPreferredItemHeightSmall. So if you need you can specify your own values or remove this lines and rely on your luck.

like image 39
x90 Avatar answered Nov 14 '22 23:11

x90