How to put a View into Bundle

后端 未结 4 2395
梦毁少年i
梦毁少年i 2021-02-20 11:59

I\'m adding dynamically created EditTexts to a layout (onClick button method). When I rotate the screen the added edittexts disappear. How can I add them to a bundle to put them

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-20 12:22

    you can't save a view. bundle is just a pair name-value. of course you can save the text and then render it again. the way is just you said.

    onsaveInsatnceState(bundle save) save the text as save.putString('text1','bla bla') of course you need a loop to save all your edittext.

    then in oncreated( bundle save)

    you can get what you have added by save.getString('text1')

提交回复
热议问题