玩转FragmentTabHost,实现底部导航栏
三步实现
-
在布局文件下添加FragmentTabHost导航栏(三个注意事项
1.在其上添加一个FrameLayout--底部变换真正内容在这里展示
2.FragmentTabHost的id为android:id="@android:id/tabhost"
3.子布局FrameLayout的id为android:id="@android:id/tabcontent")
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.wws.admin.cnscwwstest.MainActivity"> Activity继承FragmentActivity或其子布局
FragmentTabHost实例实现setup(Context context, FragmentManager manager, int containerId)方法
使用方法
1.实现setup方法后
2.实例化TabHost.TabSpec类,实现
public TabSpec setIndicator(View view)
View即为底部导航栏的布局
3.将TabSpec实例和对应的内容添加到TabHost
public void addTab(@NonNull TabHost.TabSpec tabSpec, @NonNull Class<?> clss,@Nullable Bundle args)
更多相关文章
- 为Android内核添加hello world驱动并添加到menuconfig菜单
- Android(安卓)一些网址记录
- 如何使用Android(安卓)Studio开发/调试Android源码
- Android群英传第四章笔记·ListView使用技巧
- Android(安卓)面试题7
- botoom tab + title bar
- Android(安卓)性能优化实例
- Android(安卓)实现连接MySQL数据库并进行增删改查操作
- android源码添加service