Ich versuche, eine Navigationsschublade mit einer Symbolleiste mit zwei Schaltflächen zu tun. Wenn ich auf die Knöpfe klicke, sollte zwischen zwei Fragmenten wechseln.Fragmenttransition ersetzen nicht sauber Schaltfläche
switch (v.getId()) {
case R.id.lay_publist_toolbar:
android.support.v4.app.Fragment listFrag= new PubListFragment();
FragmentManager listfragmentManager = getSupportFragmentManager();
FragmentTransaction listfragmentTransaction = listfragmentManager.beginTransaction();
listfragmentTransaction.replace(R.id.lay_hole_fragment, listFrag,"i")
.addToBackStack(null)
.commit();
break;
case R.id.lay_maplist_toolbar:
android.support.v4.app.Fragment nextFrag= new MapsActivity();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.lay_hole_fragment, nextFrag,"d")
.addToBackStack(null)
.commit();
break;
Die xml des mainactivity
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar">
</include>
<FrameLayout
android:id="@+id/lay_hole_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Solo"
android:layout_gravity="center_horizontal|top" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/common_google_signin_btn_icon_light_normal"
android:layout_gravity="center" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click here"
android:layout_gravity="left|center_vertical" />
</FrameLayout>
...
Im ersten Fall nichts im Inneren des Frameayout gereinigt wird. Im zweiten Fall implementiert das Fragment ein Google Maps und alles innerhalb des FrameLayout wird bereinigt, außer dem Button. Ich weiß, dass ich die Sichtbarkeit der Schaltfläche ändern könnte. Irgendwelche Hilfe, warum dieses Verhalten?
lösen Sie das Problem nicht der Taste verwenden. Aber eigentlich ist es besser, zwischen den beiden Fragmenten zu wechseln, danke – manolodewiner