2014-09-09 5 views
0

RelativeLayout 안에 ListView을 넣으려고합니다. 그러나 다음과 같은 오류가 발생합니다.ListView를 RelativeLayout에 넣을 수 있습니까?

  • 루트 요소 뒤에 오는 문서의 마크 업은 올바른 형식이어야합니다.
  • 오류 : XML을 구문 분석하는 동안 오류가 발생했습니다. 문서 요소 뒤에 junk가 있습니다.

LinearLayout 안에 2를 넣을 수있는 이유가 무엇인지 이해가 안됩니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relative_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

     <ListView 
     android:id="@+id/listview" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/background" /> 

    </RelativeLayout> 

답변

1

당신은 <RelativeLayout> 너무 일찍 마감하고 있습니다 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/relative_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"/> <- this is wrong 

가 마지막에 />을 제거하고, 단지 그것을 >합니다이 방법을 시도

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relative_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ListView 
    android:id="@+id/listview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:background="@drawable/background" /> 

</RelativeLayout> 
+0

대단히 감사합니다. 이것은 내 문제를 해결했다. 가능한 빨리 답변을 수락하겠습니다. 좋은 하루 되세요 :) – Pierre

0

을,이 희망 문제 해결에 도움이 될 것입니다.

If you have only ListView then you can achieved this way : 

<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:background="@drawable/background" />