I am developing an application that uses fragments, last week my test device accepted the lolipop update. When I test my application on a lolipop device, I saw that the Fragment Transaction replacement method is not working properly.
It works with confusion in the Lolipop version, although everything is fine on the Kitkat version.
To explain my situation, I added some images.
- First screen ---------------------------- KitKat -------------- ---- ------------------- lollipop -------------



As you can see, when I use kitkat , everything is fine, but as soon as I use lolipop fragment transaction lolipop , it works dimly.
Here is my button code;
mButtonOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FeedbackFragment mFragmentFeedBack = new FeedbackFragment(); android.app.FragmentManager fm = getFragmentManager(); fm.executePendingTransactions(); android.app.FragmentTransaction fragmentTransaction = fm.beginTransaction(); if (mFragmentFeedBack.isVisible()) { fragmentTransaction.hide(mFragmentFeedBack); } else { if (!mFragmentFeedBack.isAdded()) { fragmentTransaction.replace(R.id.containerfragment, mFragmentFeedBack); } fragmentTransaction.show(mFragmentFeedBack); } fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } });
here is my xml;
<RelativeLayout 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" tools:context=".MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="117dp" /> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/containerfragment"> </FrameLayout>
EDIT: Kitkat version works on the tablet, but I tried my application on the phone (Kitkat version), same thing. Without changes.
Thanks.
salih source share