接上一篇文章 https://blog.csdn.net/zhu_nana/article/details/108242189
相对上一篇文章简单,且功能多
FragmentA 嵌套FragmentB
public void onClick(View ve) {
FragmentTransaction ft2 = getFragmentManager().beginTransaction();
ft2.replace(R.id.fragment_a, new FragmentB(position));//点击图片的position
ft2.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft2.addToBackStack(null);
ft2.commit();
}
FragmentB.java
private View view;
private int pos;
public FragmentB(int pos){
this.pos = pos;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_b, container, false);
final int[] imageResI