Closed RezaKardoost closed 6 years ago
I think caching View in BaseFragment class is unnecessary and we must inflate it again whenever onCreateView is called. I Removed if statement in this code:
if (cachedView == null) { cachedView = inflater.inflate(R.layout.fragment_main, container, false); btn = cachedView.findViewById(R.id.button); }
according to : https://inthecheesefactory.com/blog/fragment-state-saving-best-practices/en
And this is also the reason why those View without android:id defined isn't able to restore its View's state.
then for save and restore state of CheckBox , I added an Id for it. every thing is ok without caching.
You are correct. https://github.com/ncapdevi/FragNav/commit/6b750fd381af1c52f4863ca615879421c0713170/
Thanks!
I think caching View in BaseFragment class is unnecessary and we must inflate it again whenever onCreateView is called. I Removed if statement in this code:
according to : https://inthecheesefactory.com/blog/fragment-state-saving-best-practices/en
then for save and restore state of CheckBox , I added an Id for it. every thing is ok without caching.