当fragment使用addToBackStack(null)方法并且在一个activity中多次点击一个方法时,fragment页面每次都会保存到back stack,当我按back键时,它会恢复相同的页面,如何将相同的fragment添加到stack中一度?
mSettingBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
SettingFragment settingFragment = new SettingFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
transaction.replace(R.id.left_framelayout, settingFragment);
transaction.addToBackStack(null);
transaction.commit();
}
});