android - FragmenManager replace makes overlay -
i'm using supportlib v4 reach master-detail flow.
problem: new instance of "details" fragment overlays first 1 (xml created) instead replace it.
my activity layout is:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context=".tracklistactivity" > <fragment android:id="@+id/fragmentlist" android:name="pl.com.digita.bikecomputerui.tracklist.tracklistfragment" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> <fragment android:id="@+id/fragmenttrack" android:name="pl.com.digita.bikecomputerui.tracklist.trackinfofragment" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" /> </linearlayout>
method called after click:
private void showdetails(long trackid){ view fragmentcontainer = getactivity().findviewbyid(r.id.fragmenttrack); trackinfofragment trackinfofragment = trackinfofragment.newinstance(trackid); fragmentmanager fragmentmanager = getfragmentmanager(); fragmentmanager.begintransaction().replace(fragmentcontainer.getid(), trackinfofragment).commit(); }
note: when add fragment activity layout defining fragment in layout xml file, cannot remove fragment @ runtime. if plan swap fragments in , out during user interaction, must add fragment activity when activity first starts, shown in next lesson.
which last thing on http://developer.android.com/training/basics/fragments/creating.html
Comments
Post a Comment