简体   繁体   English

Android Expandable ListView状态无法在方向更改时正确保存

[英]Android Expandable ListView State not saving Properly on orientation change

Hi Everyone iam having trouble with expandable Listview inside fragment while orientation change . 大家好,我在方向更改时无法在片段内部使用可扩展的Listview。 i have a list fragment on left and on click of item details fragment will be shown on right; 我在左侧有一个列表片段,在单击项目详细信息时,片段将显示在右侧; on details fragment user has chance to edit items in the expandable listview whenver user enter his details and perform a orientation change all the data entered in expandable lsitview child is reset i tried using all options like my activity is not recreating on orientation change and also used setRetainInstance(true); 在详细信息上,每当用户输入其详细信息并进行方向更改时,片段用户就有机会编辑可扩展列表视图中的项目setRetainInstance(true); but didn't work for me 但对我没用

You need to get the content of your EditText / TextView / whatever in onSaveInstanceState , and store them in the bundle. 您需要在onSaveInstanceState获取EditText / TextView /的内容,并将其存储在onSaveInstanceState包中。 When you Activity / Fragment gets recreated, retrieve your content from the bundle in onCreate . 当您重新创建Activity / Fragment时,请从onCreate的包中检索内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM