IT/안드로이드+JAVA

[안드로이드] 프래그먼트 안에 프래그먼트

안경 쓴 귀니 2016. 8. 2. 09:28
반응형


[안드로이드] 프래그먼트 안에 프래그먼트



onCreate에서 기본으로 1_1로 셋팅

ArrayList<Fragment> list;
Fragment frag = new Fragment1_1();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_place2, frag);
fragmentTransaction.commit();

final ArrayList<Fragment> list = new ArrayList<Fragment>();

list.add(new Fragment1_1());
list.add(new Fragment1_2());



버튼 리스너에 따라 1, 2 바뀜


frag2 = new Fragment1_1();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_place2, frag2);
fragmentTransaction.commit();
frag2 = new Fragment1_2();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_place2, frag2);
fragmentTransaction.commit();




반응형