tabhost上的Android添加按钮

时间:2012-12-10 15:08:43

标签: android android-tabhost

我想在标签主机顶部做一个按钮布局。我怎样才能做到这一点?给我这个错误:“根元素之后的文档中的标记必须是格式良好的”

2 个答案:

答案 0 :(得分:0)

这是我的代码感谢您的帮助。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
    <TableLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TableRow
        android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <Button android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/btn"
     android:text="osman"/>
   </TableRow>
   </TableLayout>
<TableLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TableRow
        android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

<TabHost 
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>     
</TabHost>
</TableRow>
</TableLayout>

 </LinearLayout>

答案 1 :(得分:0)

我发现如何添加它。

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TableRow 
        android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<Button android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/btnGarsonCagir"
     android:text="GARSON ÇAĞIR"
     android:layout_weight="1"/>
 <Button android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/btnTaksiCagir"
     android:text="TAKSİ ÇAĞIR"
     android:layout_weight="1"/>
    <Button android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/btnHesapIste"
     android:text="HESAP İSTE"
     android:layout_weight="1"/>
     <Button android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/btnSepet"
     android:text="SEPETİM"
     android:layout_weight="1"/>
  </TableRow>
  </TableLayout>

<TabHost 
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
 </LinearLayout>     
</TabHost>
</LinearLayout>
相关问题