如何在eclipse中引用android框架资源?

时间:2013-11-26 09:45:08

标签: java android eclipse

我想使用已在框架中定义的资源ID edittext_container

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@*android:id/edittext_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dip"
    android:orientation="vertical">

    <TextView android:id="@+android:id/message"
        style="?android:attr/textAppearanceSmall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="?android:attr/textColorSecondary" />

</LinearLayout>

但Eclipse构建错误:

Illegal resource reference: @*android resources are private and not always present

如何解决?

此ID位于http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/res/res/layout/preference_dialog_edittext.xml

2 个答案:

答案 0 :(得分:3)

您无法参考Android私人资源。但您可以复制它们并将其放在您自己的项目资源文件夹中。

您可以在https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r2.3/core/res/res/

找到所有这些内容

但是,这些主题/样式可能是嵌套的,并且具有深度依赖性。您需要从原始文件中提取大量内容。

答案 1 :(得分:0)

也许你应该写:

android:id="@android:id/edittext_container"

没有*