我正在使用选项卡式活动,并且我有三个带有相应片段的选项卡。现在,我想在更改选项卡时显示在每个片段上显示的页脚。这可能吗??请给我一个简单的例子
问问题
354 次
1 回答
1
页脚布局您将粘贴到选项卡主机 xml 下方的选项卡式活动布局中
喜欢
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TabHost
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TabHost>
<LinearLayout
android:id="@+id/footer"
android:layout_below="@android:id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</LinearLayout>
</RelativeLayout>
之后,根据选项卡选择在页脚中更改视图,如下所示
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String s) {
//Add view into footer or hide
}
});
于 2016-12-29T10:34:56.467 回答