我有一个片段用作表单,我动态使用方法EditText
上的Checkbox
和onCreateView
视图填充它。我希望能够保存他们的状态是否有另一个片段在那个之上:
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, fragment)
.addToBackStack(fragment.getTagText())
.commit();
当该片段弹出堆栈时,擦除这些子视图onBackPressed
。我怎样才能做到这一点?
答案 0 :(得分:0)
保存您的状态Bandle
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
从Bandle
恢复:
public void onCreateView(ViewGroup container, Bundle savedInstanceState)
或
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
或
public void onCreate(@Nullable Bundle savedInstanceState)