[英]Fragment inside a fragment android
I am working with Fragments. 我正在使用片段。
See the image below. 参见下图。
can we hold different activity's(Activity A) fragment(Fragmet A1) inside a fragment(Fragment B2) of another activity(Activity B)? 我们可以在另一个活动(活动B)的片段(片段B2)中保存不同活动的(活动A)片段(Fragmet A1)吗?
Is it possible how can we do this ? 我们有可能怎么做?
public void addInnerFrag() {
getChildFragmentManager().beginTransaction().add(R.id.fragContainer, new InnerFrag()).commit();
getChildFragmentManager().executePendingTransactions();
}
yes it is possible we can place fragment inside another fragment. 是的,有可能我们可以将片段放置在另一个片段内。
the solution is while you adding the fragment you will use getFragmentManager()
. 解决方案是在添加片段时,将使用
getFragmentManager()
。 while adding the child fragment inside the fragment you have to use getChildFragmentManager()
; 在子片段中添加子片段时,必须使用
getChildFragmentManager()
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.