I know the number 2 http://developer.android.com/guide/components/fragments.html I wonder what comes from "Fragment Active" when I rotate the screen and finally return to "Fragment Active".
The story of my question is that I have an application that works great, regardless of whether I start it in portrait or landscape mode. But when the screen rotates, it unloads
Fragment com.bla.bla did not create a view.
This snippet has basically only implemented onCreateView, nothing else
public View onCreateView(LayoutInflater i, ViewGroup c, Bundle s) { return i.inflate(R.layout.mylayout, c, false); }
Knowing what exactly happens when the screen is rotated, I hope to solve the problem ...
EDIT:
I tried what the commentator suggested, and some more information about it. Thus, all of them basically offer to have an empty action layout and add fragments programmatically, if I see it correctly. I have main.xml for the portrait and one for the landscape, both look very similar (the difference is horizontal and vertical):
main.xml:
<LinearLayout xmlns:android="http:// and so on" android:layout_width="fill_parent" android:layout_heigt="wrap_content" android:orientation=vertical" android:id="@+id/myContainer"> </LinearLayout>
The onCreate method of my activity is as follows:
super.onCreate(savedInstanceBundle); setContentView(R.layout.main); Fragment1 f1 = newFragment1(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.myContainer, f1);
It seems that the screen rotation works with it (so thanks so far!), But in the landscape I see only the first fragment in the portrait, which I see both the second and second time (the more I rotate, the more often they are added) , So either I have a problem with the layout, or I can’t add some fragments like this. Still trying to figure out if this is a layout issue, but there is no clue yet. Any hint?
android android-fragments
Andyandroid
source share