TabHost怎才可以编辑其他的TAB界面?
我用TABHOST做了几个TAB,但图形窗口只显示第一个TAB,其他TAB都给遮住了。我想编辑其他TAB的里面的内容,但除了在代码里调整一些距离外,没办法直观地在Graphical Layout里直接图形化移动控件。
我的布局文件如下,请问有没什么问题和怎编辑?
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:background="@drawable/backgroundred"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@android:id/tabs" >
<RelativeLayout
android:id="@+id/tabFirst"
android:layout_width="fill_parent"
android:layout_height="359dp"
android:orientation="vertical"
android:title="@string/homeText" >
<RelativeLayout
android:id="@+id/lButton"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:background="@drawable/lk" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/unButton"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:background="@drawable/unlk" >
</RelativeLayout>
</RelativeLayout>
<RelativeLayout android:id="@+id/tabSecond"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<DigitalClock
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</DigitalClock>
</RelativeLayout>
<RelativeLayout android:id="@+id/tabSetting"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<View
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bkwhite"
android:visibility="visible" />
</RelativeLayout>
<RelativeLayout android:id="@+id/tabHis"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<DigitalClock
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</DigitalClock>
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
</TabHost>
如下图,无论我点底部的什么TAB,它还是第一个TAB的画面,就无法编辑其他TAB里的控件的位置。
请问怎可以编辑其他TAB的内容呢?除了代码的方式外
--------------------编程问答-------------------- 弱弱问一句,你的radiogroup加id了吗,每个radio加点击事件了吗?都没有怎么改变了? --------------------编程问答-------------------- tabhost 的上面界面一般是单独的layout布局 跟tabhost不一定非要在一个布局文件中。用代码add到tabhost中就可以了 --------------------编程问答-------------------- private TabHost mTabHost;
private TabManager mTabManager;
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
mTabManager = new TabManager(this, mTabHost, R.id.real_tab_content);
mTabManager.addTab(mTabHost.newTabSpec("tab_home").setIndicator("Home"), Test1.class, null);
mTabManager.addTab(mTabHost.newTabSpec("tab_one").setIndicator("One"), Test2.class, null); --------------------编程问答--------------------
根据您的意思,我先添加一个XML文件在LAYOUT下。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/settings"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bkwhite" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="设置"
android:gravity="center"
android:textSize="30sp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="50dp"
android:text="系列号:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="90dp"
android:text="密 码:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="@+id/snText"
android:layout_width="179dp"
android:layout_height="28dp"
android:layout_marginLeft="70dp"
android:layout_marginTop="50dp"
android:ems="10"
android:hint="请输入系列号"
android:inputType="text"
android:textSize="@dimen/ten" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/pwdText"
android:layout_width="179dp"
android:layout_height="28dp"
android:layout_marginLeft="70dp"
android:layout_marginTop="90dp"
android:ems="10"
android:hint="请输入密码"
android:inputType="text"
android:textSize="@dimen/ten" />
</FrameLayout>
然后点CLEAN,发现一大堆错误,R.JAVA也不见了。
请问哪错了? --------------------编程问答-------------------- 我再简化了点这个TAB
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是tab的第二个界面">
</TextView>
</LinearLayout>
创建到layout下命名为abc.xml
怎加进TABHOST里?
--------------------编程问答-------------------- 网上应该有实例代码,你找找吧 --------------------编程问答-------------------- 就是没找到这样的…… --------------------编程问答-------------------- 获取别的tab界面的实例 然后改呗
补充:移动开发 , Android