2014-07-06 8 views
1

필자는 내 상대적 레이아웃에 하나의 목록보기와 하나의 버튼을 가지고 있습니다.버튼이 에뮬레이터에 표시되지 않음

Eclipse 그래픽보기로 표시됩니다. 하지만 에뮬레이터 listview에서만 보여줍니다. 버튼이 에뮬레이터에 표시되지 않습니다.

여기 내 XML 코드

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 


<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="415dp" > 
</ListView> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/listView1" 
    android:layout_centerHorizontal="true" 
    android:onClick="submit" 
    android:text="SUBMIT" /> 

</RelativeLayout> 

내 매니페스트 코드

<uses-sdk 
android:minSdkVersion="14" 
android:targetSdkVersion="19" /> 


<activity android:name="com.androidexample.tabbar.Tab1" 
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"> 
</activity> 
도와

감사합니다 .. 다음

답변

1

내 오래된 코드를 지우고 새로운 상대 레이아웃을 만든 다음 올바르게 작동합니다.

원인 오류 선형 레이아웃을 상대 레이아웃으로 수동으로 변환합니다..

수정 후 내 코드입니다 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="420dp" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" > 
</ListView> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="14dp" 
    android:text="Button" 
    android:onClick="submit"/> 

</RelativeLayout> 
1

사용 :

<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:[email protected]"+id/button1" > 
</ListView> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    android:onClick="submit" 
    android:text="SUBMIT" /> 
관련 문제