프래그먼트B의 Argument로 열고자 하는 탭인덱스를 전달하세요.
// FragmentA
getSupportFragmentManager()
.beginTransaction()
.replace(..., FragmentB.newInstance(1), ...)
.commit();
// FragmentB
private static final String TAB_INDEX = "tabIndex";
private static final int DEFAULT_TAB_INDEX = 0;
public static FragmentB newInstance(int tabIndex) {
FragmentB fragmentB = new FragmentB();
Bundle bundle = new Bundle();
bundle.putShort(FragmentB.TAB_INDEX, 1);
fragmentB.setArguments(bundle);
return fragmentB;
}
@Override
public void onViewCreated (View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getArguments() != null) {
short tabIndex = getArguments().getShort(TAB_INDEX, DEFAULT_TAB_INDEX);
// TODO : 탭인덱스 설정
}
}