2012-04-29 129 views
-1

什麼在此代碼錯誤,請讓我知道的方法,這方法是否正確。什麼是佈局代碼錯誤

當我加載列表項,列表被擴展至搜索欄,而不是整個屏幕。請指教我。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:background="#000044"> 

     <TableRow> 
      <EditText 
       android:id="@+id/txtUserName" 
       android:width="270dp" /> 

      <Button 
       android:id="@+id/Search_button" 
       android:width="50dp" /> 
       /> 
     </TableRow> 

     <TableRow> 
      <ListView 
       android:id="@+id/Service_name_list" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"/> 
     </TableRow> 

    </TableLayout> 

也告訴我,這將適用於所有屏幕或不。

回答

0

更改第二行如下:

<TableRow android:layout_span="2"> 
     <ListView 
     android:id="@+id/Service_name_list" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 
    </TableRow> 

改變的唯一事情是機器人:layout_span = 「2」,也就是等於HTML列跨度。

+0

它沒有工作:( – Naruto 2012-04-29 12:30:56

0

添加layout_span迫使一個細胞跨過兩個單元。

<ListView 
    android:id="@+id/Service_name_list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_span="2"/>