I have a problem with saving fragment state. I try to use setRetainInstance, but cant make it work((( I change a state to 2 using button1, but after changing screen orientat
There isn't anything wrong with the code you posted. If you have the fragment implemented correctly, it should be giving you a state of 2. Maybe you could post your activity and xml files. There error must be somewhere else.
Your fragment will only get re-used if you give the fragment an Id in the layout, change
<fragment
android:name="ru.ee.TestFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
to be
<fragment
android:id="@+id/a_fragment"
android:name="ru.ee.TestFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>