Here is a screenshot of my tablet application (not using fragments for now):
So as you can see, there is a little menu on the left with icon for each one of my activities.
Currently, these icons launches new activities, but I would like them to launch fragmentactivity in the frame on the right, so everything would be in the same pannel.
But after reading carefully posts and docs about fragments, I can only see that fragments are displayed at the same time:
from here: http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment class="com.example.android.开发者_开发问答apis.app.TitlesFragment"
android:id="@+id/titles" android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
<FrameLayout android:id="@+id/details" android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
</LinearLayout>
So, in order to display different fragments in the same place, what should I do? I guess that playing on View=gone is the worst idea I can have, isn't it?
Thank a lot for any help.
You have to migrate your activities to fragments. You will then have, for example, a RoutePlanner
fragment, a TrafficIssues
fragment, etc. When one of the icons is pressed, you will use the FragmentManager
to replace the details FrameLayout
with the corresponding fragment.
精彩评论