私は、フラグメントをホストする唯一の目的を持つアクティビティを持っています。私はこのアクティビティをインテントで開始してから、インテントの情報を使用して、新しいアクティビティに追加したいフラグメントに引数を追加します。コミット後にフラグメントから消えるバンドル?
ここでは、SingleClickerActivityのonCreate(このアクティビティはインテントによって開始されます)です。これを進めていくうちに、断片に私が送りたい議論があることが確認されました。 Fragment has argument (this is right before the transaction step)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResId());
UUID clickerId = (UUID) getIntent().getSerializableExtra(EXTRA_CLICKER_ID);
FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentById(R.id.fragment_container);
if (fragment == null) {
fragment = createFragment(clickerId);
fm.beginTransaction()
.add(R.id.fragment_container, fragment)
.commit();
}
}
私はフラグメントが、それは引数バンドルを持っている、と私はそれをコミット作りました。しかし、ときに私は、フラグメントののonCreateに行く:ヌル
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mClickerId = (UUID) getArguments().getSerializable(ARG_CLICKER_ID);
mClicker = ClickerBox.get(getActivity()).getClicker(mClickerId);
}
戻ります。バンドルにはうがいがあります。どこが失われていますか?