2012-07-10 58 views
0

我试图显示表layout.In,我有以下错误:的Android(表布局)

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.budget1/com.budget1.Report}: android.view.InflateException: Binary XML file line #2: Error inflating class Tablelayout 

我的XML代码:

<?xml version="1.0" encoding="utf-8"?> 
<Tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <Tablerow> 
<Textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enter your name"> 
    </Textview> 
    <Edittext android:layout_width="150px" android:layout_height="wrap_content"> 
     </Edittext> 
    <Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Submit" 
    /> 
    </Tablerow> 

<Tablerow> 
<Textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Spanning Two columns" android:layout_span="2"> 
    </Textview> 
    <Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Cancel" 
    /> 
</Tablerow> 

</Tablelayout> 

请帮助我..

回答

2

Android布局xml文件区分大小写。使用TableLayout,TableRow,TextView,EditText等。

+0

由于其工作... – 2012-07-10 09:48:56

0

您没有为布局组件指定Ids。尝试添加一个唯一的ID为每个的TableRow,TextView的,...等使用参数android:id="@+id/your_desired_id"

0

我编辑你这样的XML文件,它的做工精细,

<TableLayout 

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

    <TableRow 
      android:id="@+id/tableRow1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Enter your name" 
       /> 


     <EditText 
        android:layout_width="150px" 
        android:layout_height="wrap_content" 
       /> 


     <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Submit" 
       /> 
    </TableRow> 

    <TableRow 

     android:id="@+id/tableRow2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <TextView 
       android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Spanning Two columns" 
        android:layout_span="2" /> 

     <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Cancel" 
       /> 
    </TableRow> 

    </TableLayout> 
+0

谢谢vishwa..for尝试...我得到了答案...我想在表中的每一行之间有空间..怎么做。 – 2012-07-10 10:02:48

+0

嗨,把android:layout_marginTop =“10px”在你的第二个表中作为属性 – 2012-07-10 10:07:35

+0

感谢vishwa.Its工作..一个更多vishwa(不要误会我)..是否有可能在表格布局中显示行之间的分隔。 – 2012-07-10 10:16:35