FragmentTabhost学习笔记
来源:互联网 发布:如何雇佣网络水军 编辑:程序博客网 时间:2024/04/26 12:04
首先看下官方解释:
Special TabHost that allows the use of Fragment
objects for its tab content. When placing this in a view hierarchy, after inflating the hierarchy you must call setup(Context, FragmentManager, int)
to complete the initialization of the tab host.
Here is a simple example of using a FragmentTabHost in an Activity:
import com.example.android.supportv4.R;import android.os.Bundle;import android.support.v4.app.FragmentActivity;import android.support.v4.app.FragmentTabHost;/** * This demonstrates how you can implement switching between the tabs of a * TabHost through fragments, using FragmentTabHost. */public class FragmentTabs extends FragmentActivity { private FragmentTabHost mTabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs); mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"), FragmentStackSupport.CountingFragment.class, null); mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"), LoaderCursorSupport.CursorLoaderListFragment.class, null); mTabHost.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"), LoaderCustomSupport.AppListFragment.class, null); mTabHost.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"), LoaderThrottleSupport.ThrottledLoaderListFragment.class, null); }}看到这里的时候我有一个地方么有看明白:
public void setup (Context context, FragmentManager manager, int containerId)
containerId我的理解是“存放的页面内容ID” 请看layout.xml文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <!-- 存放页面内容 --> <FrameLayout android:id="@+id/realtabcontent" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" /> <!-- 底层菜单 --> <android.support.v4.app.FragmentTabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/mainfragmenttabs_bottombar"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="0" /> </android.support.v4.app.FragmentTabHost></LinearLayout>
参考学习:http://blog.csdn.net/xiaoyuan511/article/details/24882979
http://www.jianshu.com/p/3b0ff7a4bde1
0 0
- FragmentTabhost学习笔记
- Android学习笔记:TabHost 和 FragmentTabHost
- Android学习笔记:TabHost 和 FragmentTabHost
- Android学习笔记:TabHost 和 FragmentTabHost
- Android学习笔记:TabHost 和 FragmentTabHost
- Android学习笔记:TabHost 和 FragmentTabHost
- Android学习笔记--FragmentTabHost完成首页布局
- FragmentTabHost 笔记
- FragmentTabHost 笔记
- 学习笔记 Tianmao 篇 FragmentTabHost (TabHost升级版)
- 学习笔记之——FragmentTabHost实现中间按钮凸出效果
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- Android 截屏并保存
- css 长单词不换行溢出容器的解决方法 word-wrap与word-break
- centos配置mutt跟msmtp发送邮件
- phpredis中文手册——《redis中文手册》 php版
- 16其他UI内容
- FragmentTabhost学习笔记
- Genymotion出现”Unable to load VirtualBox engine“的问题解决
- float和double的内存布局
- 内存溢出java.lang.OutOfMemoryError解决方法
- MSDN中对MSBuild的解释页
- 17多线程原理 & NSThread
- poj1543Perfect Cubes
- 18.GCD
- delphi自定义颜色