2012-04-29 127 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"/>