2012-07-16 3 views
1

저는 안드로이드 앱 개발을 처음 사용합니다.안드로이드에서 ListView가 보이지 않습니다.

이것은 내 xml 레이아웃 파일입니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="horizontal" > 
<Button 
    android:layout_weight="0.5" 
    android:id="@+id/back" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/cancel"/> 

<Button 
    android:layout_weight="0.5" 
    android:layout_gravity="right" 
    android:id="@+id/editall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/editall"/> 
</LinearLayout> 
<ListView 
    android:id="@android:id/list" 
    android:cacheColorHint="#00000000" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fadingEdge="none"/> 
</LinearLayout> 

여기에서 버튼을 볼 수 있지만 목록보기가 표시되지 않습니다. 어떤 몸이라도 제발 도와주세요. 미리 감사드립니다

답변

4

fill_parent 대신에 wrap_content을 버튼 선형 레이아웃으로 바꿉니다. fill_parent에서

변화

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" > 
<Button 
    android:layout_weight="0.5" 
    android:id="@+id/back" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/cancel"/> 

<Button 
    android:layout_weight="0.5" 
    android:layout_gravity="right" 
    android:id="@+id/editall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/editall"/> 
</LinearLayout> 
<ListView 
    android:id="@android:id/list" 
    android:cacheColorHint="#00000000" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fadingEdge="none"/> 
</LinearLayout> 
+0

덕분에 나는 이것을 보지 못했습니다. 감사합니다. –

+0

그리고 ListView에'android : layout_height = "fill_parent"를 넣어서 나머지 공간을 모두 가져갈 수도 있습니다 – fiddler

0

변경 내부 선형 레이아웃의 높이를 wrap_content합니다.

목록보기

0

을 숨길 부모의 전체 높이를 다룰 것입니다 높이 fill_parent를 제공하기 때문에 당신은 또한 당신의 onCreate()ListView에 대한 Adapter을 설정 했습니까? 비어있는 경우 아무 것도 화면에 표시되지 않습니다. cacheColorHint을 사용하여 투명한 배경을 설정하고 wrap_content 높이를 컨테이너에 적용 했으므로 아무 것도 표시되지 않습니다.

관련 문제