How to retain EditText data on orientation change?

后端 未结 12 1913
暗喜
暗喜 2020-12-05 13:34

I have a Login screen which consists of 2 EditTexts for Username and Password. My requirement is that on orientation change , input data(if any) in EditText should r

12条回答
  •  春和景丽
    2020-12-05 14:19

    Below code is work for me. Need to care two things.

    1. Each Input Field (Edit Text or TextInputEditText) assign unique id.
    2. Manifest activity declaration should have on configuration change attribute with below values.

      android:configChanges="orientation|keyboardHidden|screenSize"

    Sample activity declaration in manifest.

    
    

    Sample declaration of

     
    
            
        
    

提交回复
热议问题