首页 文章

选项卡式活动中的页脚

提问于
浏览
0

我正在使用 Tabbed Activity ,我有三个带有相应片段的标签 . 现在我想在我更改Tab时显示每个片段上显示的页脚 . 这可能吗??请举个简单的例子

1 回答

  • 1

    页脚布局u将粘贴到选项卡主机xml下面的 Tabbed activity layout

    喜欢

    <?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 
                }
            });
    

相关问题