I'm using ListFragment and implementing LoaderManager.LoaderCallbacks from Android compatibility package for showing a list view in the app. The list is showing fine but when orientation changes, the list view is not proper (I think the view is overlapping on the previous one)
Picture here: list-view-after-orientation-change
Has anyone faced the same issue before? Could you let me know what might have been the issue or if any more details need to be provided.
I found the error. It is due to creating list fragment every time when the activity is created, even if due to config change. But by default, android retains the fragment during the recreation of the activity during config changes.
Doing this solved my problem. Create fragment only if savedInstanceState is null.
if(savedInstanceState == null) {
// Initialize fragment here.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With