Android xml 오류: RelativeLayout(@id/LinearLayout_acc, @id/ProgressBar_statusScreen)이 있는 "지정된 이름과 일치하는 리소스를 찾을 수 없습니다"
자, 이제 정말 짜증이 나기 시작했습니다.이 오류는 매우 특별하고 논리적이지 않은 방식으로 나타납니다.
먼저 이 오류와 관련된 다른 질문들을 이미 살펴보았습니다. 구글도 마찬가지였습니다.내가 말할 수 있는 한, 대부분의 유사한 문제들은 사람들이 언급하기 때문에 발생합니다.String리소스 또는 다른 것이 동일한 레이아웃 파일 내에 있지 않으면 '@id+' 또는 이와 유사한 것에 '+'를 잘못 배치합니다.
제가 겪고 있는 문제는 layout.xml 파일에서 발생합니다.RelativeLayout여기에는 다음이 포함됩니다.TableLayout,두명LinearLayout일부 텍스트와 마지막으로 a를 포함합니다.ProgressBar내가 원하는 것은 다음을 사용하여 진행률 표시줄을 상대 레이아웃과 정렬하는 것입니다.android:layout_alignParentBottom="true"그런 다음 두 개의 선형 레이아웃을 진행률 표시줄 위에 정렬합니다(진행률 표시줄 위에 정렬되는 하단 선형 레이아웃, 다른 하나는 하단 선형 레이아웃 위에 정렬).
이는 충분히 간단해야 하며 작동하는 것처럼 보여야 합니다. 즉, 그래픽 보기에 원하는 결과가 표시됩니다.하지만 문제가 발생했습니다. Eclipse는 두 개의 선형 레이아웃에 대한 오류를 제공합니다.
"오류: 지정된 이름과 일치하는 리소스를 찾을 수 없습니다(값이 '@id/LinearLayout_acc'인 'layout_above')."
진행 표시줄을 참조하는 다른 선형 레이아웃에 대해서도 동일한 오류가 발생합니다.저는 오타가 없는 것을 3번 이상 확인했습니다(아이디도 패키지 이름에 있습니다.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/그 후, 첫 번째 시간이 정의가 아닐 수도 있지만,
저는 대부분의 디자인을 만들고 이클립스의 그래픽 에디터에서 참조된 id를 설정하여 오류 메시지가 발생하는 코드가 자동으로 삽입되었습니다.아마도 이것은 이클립스의 버그일 것입니다.
바꾸다
@id/LinearLayout_acc
로.
@+id/LinearLayout_acc
아래 코드를 확인해 주세요.
<?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>
다음 링크도 확인하십시오.안드로이드:layout_below="@id/myTextView"가 ID가 "myTextView"인 요소를 사용 중인 요소 뒤에 작성하면 인식하지 못한다고 표시됩니다.
ID 하기 든경 ID 변모@id@+idID를 정의하거나 참조하는 경우에 관계없이.이것으로, 당신은 얻을 수 없습니다.
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" >
언급URL : https://stackoverflow.com/questions/11668718/android-xml-error-no-resource-found-that-matches-the-given-name-with-relative
'programing' 카테고리의 다른 글
| Git 하위 모듈을 하위 디렉터리에 추가하려면 어떻게 해야 합니까? (0) | 2023.05.04 |
|---|---|
| IPython 변수를 bash 명령에 대한 인수로 전달 (0) | 2023.05.04 |
| 명령줄을 사용하여 커밋 메시지를 검색하는 방법은 무엇입니까? (0) | 2023.05.04 |
| git: 지점이 X 커밋으로 앞서 있습니다. (0) | 2023.05.04 |
| LINQ를 사용하여 컬렉션의 모든 개체 업데이트 (0) | 2023.05.04 |