简体   繁体   English

导航抽屉使用Appcompat v7 - 问题?android:attr标签

[英]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. 使用appcompat v7和v4。

I have added the appcompat v7 WITH resources. 我添加了appcompat v7 WITH资源。

The following is my textview for the navigation drawer list taken straight from the android sample app found at Creating a Navigation Drawer 以下是直接从创建导航抽屉中找到的android示例应用程序中获取的导航抽屉列表的textview

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. 我不明白为什么没有找到属性,考虑到我添加了appcompat及其资源。 Or are they not valid with the appcompat or something? 或者他们无法使用appcompat或其他东西?

MinSDK Version is 10 and at which the code fails. MinSDK版本为10,代码失败。 Above API 10 the code works fine. 在API 10之上,代码工作正常。

<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"/>

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. 您可以使用兼容性库中定义的值:它指定除了背景之外的所有值,我选择了listChoiceBackgroundIndicator,尽管您也可以与其他人一起玩。

<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"/>

I had same issue. 我有同样的问题。 As i understand older apis haven't predefined textAppearanceListItemSmall, activatedBackgroundIndicator and listPreferredItemHeightSmall. 据我所知,旧的apis还没有预定义textAppearanceListItemSmall,activatedBackgroundIndicator和listPreferredItemHeightSmall。 So if you need you can specify your own values or remove this lines and rely on your luck. 因此,如果您需要,您可以指定自己的值或删除此行并依靠您的运气。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM