activity- (ViewPager)--->Fragment
2016-03-18 10:09
381 查看
activity的布局中书写ViewPager,然后将Fragment加入到ViewPager中
通过FragmentTransaction.add( xxx,xxx,xxx)
/**
* Add a fragment to the activity state. This fragment may optionally
* also have its view (if {@link Fragment#onCreateView Fragment.onCreateView}
* returns non-null) inserted into a container view of the activity.
*
* @param containerViewId Optional identifier of the container this fragment is
* to be placed in. If 0, it will not be placed in a container.
* @param fragment The fragment to be added. This fragment must not already
* be added to the activity.
* @param tag Optional tag name for the fragment, to later retrieve the
* fragment with {@link FragmentManager#findFragmentByTag(String)
* FragmentManager.findFragmentByTag(String)}.
*
* @return Returns the same FragmentTransaction instance.
*/
public abstract FragmentTransaction add(int containerViewId, Fragment fragment, String tag);
/**
* Calls {@link #replace(int, Fragment, String)} with a null tag.
*/
public abstract FragmentTransaction replace(int containerViewId, Fragment fragment);
/**
* Replace an existing fragment that was added to a container. This is
* essentially the same as calling {@link #remove(Fragment)} for all
* currently added fragments that were added with the same containerViewId
* and then {@link #add(int, Fragment, String)} with the same arguments
* given here.
*
* @param containerViewId Identifier of the container whose fragment(s) are
* to be replaced.
* @param fragment The new fragment to place in the container.
* @param tag Optional tag name for the fragment, to later retrieve the
* fragment with {@link FragmentManager#findFragmentByTag(String)
* FragmentManager.findFragmentByTag(String)}.
*
* @return Returns the same FragmentTransaction instance.
*/
public abstract FragmentTransaction replace(int containerViewId, Fragment fragment, String tag);
通过FragmentTransaction.add( xxx,xxx,xxx)
/**
* Add a fragment to the activity state. This fragment may optionally
* also have its view (if {@link Fragment#onCreateView Fragment.onCreateView}
* returns non-null) inserted into a container view of the activity.
*
* @param containerViewId Optional identifier of the container this fragment is
* to be placed in. If 0, it will not be placed in a container.
* @param fragment The fragment to be added. This fragment must not already
* be added to the activity.
* @param tag Optional tag name for the fragment, to later retrieve the
* fragment with {@link FragmentManager#findFragmentByTag(String)
* FragmentManager.findFragmentByTag(String)}.
*
* @return Returns the same FragmentTransaction instance.
*/
public abstract FragmentTransaction add(int containerViewId, Fragment fragment, String tag);
/**
* Calls {@link #replace(int, Fragment, String)} with a null tag.
*/
public abstract FragmentTransaction replace(int containerViewId, Fragment fragment);
/**
* Replace an existing fragment that was added to a container. This is
* essentially the same as calling {@link #remove(Fragment)} for all
* currently added fragments that were added with the same containerViewId
* and then {@link #add(int, Fragment, String)} with the same arguments
* given here.
*
* @param containerViewId Identifier of the container whose fragment(s) are
* to be replaced.
* @param fragment The new fragment to place in the container.
* @param tag Optional tag name for the fragment, to later retrieve the
* fragment with {@link FragmentManager#findFragmentByTag(String)
* FragmentManager.findFragmentByTag(String)}.
*
* @return Returns the same FragmentTransaction instance.
*/
public abstract FragmentTransaction replace(int containerViewId, Fragment fragment, String tag);
相关文章推荐
- memcached php扩展(二)
- TableView分组风格下去掉HeaderView和FooterView的方法
- SWIFT基础语法 (一)
- Qt之QLabel
- 解决绿C(C与C++程序设计学习与实验系统 2015)软件程序中文出现乱码问题
- php入门自学小展示
- TP关联模型
- 20160317 CodeVS 1025 选菜,1102 采药,3324 新斯诺克
- oracle10g 数据库导入dmp数据
- c++中string 的replace用法
- asp.net小数点四舍五入的正确写法
- 无线路由器用多少信道好?
- Pod找不到配置文件在
- JVM 并发性: Java 和 Scala 并发性基础
- 父元素与子元素之间的margin-top问题(css hack)
- 在Eclipse中使用JUnit4进行单元测试(初级篇)
- java实现定时任务的三种方法
- FreeRTOS系列第20篇---FreeRTOS信号量API函数
- linux tcp超时重传实现分析
- redis 服务器端安装(三)