How to save the state of fragment when vyzyvaetsya FragmentTransaction.detach()?

Good evening, Habr!

Help, who can...

Wrote a app with tabs using this manual. Faced with the problem that when switching tabs, not called onSavedInstanseState fragment in the current tab, and switch back are all the calls in order, and, of course, from savedInstanceState nothing is restored. How to be?
October 8th 19 at 00:31
1 answer
October 8th 19 at 00:33
Solution
Everything is easier than expected:
LinkedList savedDevicesNames = null;<br> <br / > @Override<br> public void onActivityCreated(Bundle savedInstanceState) {<br> if (D) { Log.d(TAG, "onActivityCreated"); }<br> <br / > super.onActivityCreated(savedInstanceState);<br> <br / > if (savedDevicesNames != null) {<br> for (String deviceNameAddr : savedDevicesNames) {<br> adapter.add(deviceNameAddr);<br> }<br> }<br> }<br> <br / > @Override<br> public void onDestroyView() {<br> super.onDestroyView();<br> savedDevicesNames = new LinkedList();<br> for (int i = 0; i < adapter.getCount(); i++) {<br> savedDevicesNames.add(adapter.getItem(i));<br> }<br> }

Find more questions by tags Android