Android标签符合页脚

我想在我的应用程序中为每个活动重用我的标签,如页脚.

我正在使用此代码

<TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_above="@android:id/tabs" />

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true" />

        </RelativeLayout>

    </TabHost>

我想在每个布局的标签上添加ListView,Button等组件.我该怎么办呢?

最佳答案 我通过扩展一个公共基本活动做了类似的事情,其中​​我重写了方法setContentView.

abstract public class BaseActivity extends Activity {
    @Override
    public void setContentView(View view) {

        // get master
        LayoutInflater inflater = LayoutInflater.from(this);

        // this is the master view with a container and the footer, you can
        // as well add the header
        RelativeLayout rlMasterView = (RelativeLayout) inflater.inflate(R.layout.master, null);

        rlMasterView.addView(view);

        super.setContentView(rlMasterView);
    }
}

setContentView创建页脚并将其附加到我在每个活动中设置的视图中.

我也可以在每个布局中使用include标记.

<include src="footer" />
点赞