[android] Android xml 오류 : RelativeLayout (@ id / LinearLayout_acc, @ id / ProgressBar_statusScreen)을 사용하는 “주어진 이름과 일치하는 리소스를 찾을 수 없음”

좋아요, 이건 정말 짜증나 기 시작했습니다. 이 오류는 논리적이지 않은 매우 특별한 방식으로 나타납니다.

이 오류와 관련된 다른 질문을 이미 살펴 보았습니다. Google도 마찬가지입니다. 내가 말할 수있는 한, 사람들 String이 동일한 레이아웃 파일 내에없는 리소스 또는 다른 것을 참조하기 때문에 대부분의 유사한 문제가 발생합니다 . ‘@ id +’또는 이와 유사한 것으로 ‘+’를 잘못 배치했습니다.

내가 겪고있는 문제는 RelativeLayout. 여기에는 일부 텍스트 가 포함 된 TableLayout, 2 LinearLayout, 마지막으로 ProgressBar. 내가 원하는 것은 진행률 표시 줄을 사용하여 상대 레이아웃 android:layout_alignParentBottom="true"과 정렬 한 다음 진행률 표시 줄 위에 두 개의 선형 레이아웃을 정렬하는 것입니다 (진행률 표시 줄 위에 정렬되는 하단 선형 레이아웃, 하단 선형 레이아웃 위에 정렬 된 다른 선형 레이아웃).

그것은 충분히 단순해야하고 작동하는 것처럼 보여야합니다. 즉, 그래픽보기가 원하는 결과를 보여줍니다. 그러나 여기에 문제가 있습니다 . Eclipse는 두 개의 선형 레이아웃에서 오류를 제공합니다.

“오류 : 주어진 이름 ( ‘@ id / LinearLayout_acc’값이있는 ‘layout_above’에서)과 일치하는 리소스를 찾을 수 없습니다.”

진행률 표시 줄을 참조하는 다른 선형 레이아웃에서도 동일한 오류가 발생합니다. 오타가 없는지 세 번 이상 확인했으며 (ID는 packagename.R.java에도 있음) 프로젝트를 여러 번 정리해 보았습니다.

프로젝트를 실행하기 전에는 저장 (및 자동 빌드) 할 때 오류가 발생하지 않습니다. 또 다른 이상한 점은 상단 선형 레이아웃 대신 진행률 표시 줄에서 하단 선형 레이아웃을 참조 할 때 오류가 발생하지 않는다는 것입니다!

내 레이아웃 파일 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_activity" >
        <TableLayout
             ... />

        <LinearLayout
            android:id="@+id/LinearLayout_dist"
            android:layout_above="@id/LinearLayout_acc"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="10dp" >

            <TextView
                ... />

            <TextView
                ... />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/LinearLayout_acc"
            android:layout_above="@id/ProgressBar_statusScreen"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true" >

            <TextView
                ... />

            <TextView
                ... />
        </LinearLayout>

        <ProgressBar
            android:id="@+id/ProgressBar_statusScreen"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_margin="16dp" />

</RelativeLayout>

이 오류의 원인이 무엇인지 모르겠습니다.

답변으로 편집

Shrikant는 참조를 읽을 때 이미 정의 된 다른 요소 만 참조하도록 레이아웃 파일의 모양 순서를 변경하는 솔루션을 제공합니다.
다른 사람이 게시 변화하는 것처럼 또한, @id/@+id/심지어 참조, 오류 메시지를 제거한다. Marco W. 가이 스레드 에서 썼 듯이 , 첫 번째는 정의가 아닐지라도 @+id/각 ID가 언급 @id/될 때 처음 사용하고 나중에 사용해야 한다는 것입니다.

나는 대부분의 디자인을 만들고 Eclipse의 그래픽 편집기에서 참조 된 ID를 설정했기 때문에 오류 메시지가 발생한 코드가 자동으로 삽입되었습니다. 아마도 이것은 Eclipse의 버그 일 것입니다.



답변

아래 코드를 확인하세요

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/ic_launcher" >

<TableLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<LinearLayout
    android:id="@+id/LinearLayout_dist"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/LinearLayout_acc"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="10dp" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="FIRST" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="SECOND" />
   </LinearLayout>

   <LinearLayout
    android:id="@+id/LinearLayout_acc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ProgressBar_statusScreen"
    android:layout_centerHorizontal="true" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="THIRD" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="FOURTH" />
   </LinearLayout>

   <ProgressBar
    android:id="@+id/ProgressBar_statusScreen"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_margin="16dp" />

 </RelativeLayout>

또한 다음 링크를 확인하십시오 . android : layout_below = “@ id / myTextView”는 사용중인 요소 뒤에 작성되는 경우 id “myTextView”가있는 요소를 인식하지 못합니다.


답변

변화

@id/LinearLayout_acc

@+id/LinearLayout_acc


답변

ID @id@+id정의하거나 참조 할 때 모든 ID 를로 변경하십시오 . 이것으로, 당신은 얻을 수 없습니다

Android xml 오류 : RelativeLayout (@ id / LinearLayout_acc, @ id / ProgressBar_statusScreen)과 함께 “주어진 이름과 일치하는 리소스를 찾을 수 없습니다”.


답변

 <LinearLayout
        android:id="@+id/LinearLayout_dist"
        android:layout_above="@+id/LinearLayout_acc" <--- here might be a problem you forgot + sign
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp" >


답변