0

I save and restore view but I loose the edittext, checkbox and so on. With the debugger I can see all these fields are well in the "savedInstanceState" (in restore part) but not displayed; maybe setcontentview is not enough? Thank you in advance for your help. MichelF

@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putInt("Screen",screenFlag);
    savedInstanceState.putInt("PreviousScreen",previous_screenFlag);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    screenFlag = savedInstanceState.getInt("Screen");
    previous_screenFlag = savedInstanceState.getInt("PreviousScreen");
    switch (screenFlag){
        case 1:
            setContentView(R.layout.lay1);
            break;
        case 2:
            setContentView(R.layout.dlay2);
            break;
        case 3:
            setContentView(R.layout.lay3);
            break;
        default:
            home(null);
    }
}
M.Fd
  • 1
  • possible duplicate of : http://stackoverflow.com/questions/4018772/calling-setcontentview-multiple-times – Janki Gadhiya Jun 04 '16 at 09:24
  • Thank you Janki for your quick answer. However, the issue is not to switch between different layouts but to get back the edittext data as they were before a screen rotation (for example). MichelF – M.Fd Jun 04 '16 at 16:35

0 Answers0