【发布时间】:2016-04-01 20:00:10
【问题描述】:
我正在尝试扩展Android的simple_list_item_2,所以我复制了它的XML,即:
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/listPreferredItemHeight"
android:mode="twoLine"
android:paddingStart="?attr/listPreferredItemPaddingStart"
android:paddingEnd="?attr/listPreferredItemPaddingEnd">
<TextView android:id="@id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView android:id="@id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/text1"
android:layout_alignStart="@id/text1"
android:textAppearance="?attr/textAppearanceListItemSecondary" />
</TwoLineListItem>
问题是,在我的实现中,这条线
android:textAppearance="?attr/textAppearanceListItemSecondary"/>
给出错误:
Cannot resolve symbol ?attr/textAppearanceListItemSecondary
我试过这样的东西:
android:textAppearance="android:?attr/textAppearanceListItemSecondary"
和
android:textAppearance="@android?attr/textAppearanceListItemSecondary"
但它不起作用
所以我的问题是,如何访问 Android SDK 资源中的布局可以访问的相同符号/属性?我是否需要将符号复制到我的应用程序目录中,还是可以直接访问 simple_list_item_2 所做的那个?
另外,原始的simple_list_item_2 位于C:\Android\sdk\platforms\android-23\data\res\layout\,如果有帮助,我的实现位于\app\src\main\res\layout
【问题讨论】:
-
呃,我刚刚用谷歌搜索了这个,来到这里,然后意识到这是我去年问的自己的问题
标签: android xml android-layout attributes