fragmenttransaction

Android fragment transaction listener

删除回忆录丶 提交于 2020-01-04 09:28:11
问题 I need to listen when a fragment transaction is performed, for example, when I replace a fragment with another, without call to addToBackStack(). FragmentManager class provides a addOnBackStackChangedListener callback, but when I perform a fragment replacement without call to addToBackStack, it is not executed. Edit: the listen operation is performed in a class which only have access to the activity instance and its fragment manager. 回答1: You can use Base class for all your fragments. Then

Android fragment transaction listener

泪湿孤枕 提交于 2020-01-04 09:28:09
问题 I need to listen when a fragment transaction is performed, for example, when I replace a fragment with another, without call to addToBackStack(). FragmentManager class provides a addOnBackStackChangedListener callback, but when I perform a fragment replacement without call to addToBackStack, it is not executed. Edit: the listen operation is performed in a class which only have access to the activity instance and its fragment manager. 回答1: You can use Base class for all your fragments. Then

How to pass from one fragment to another

喜夏-厌秋 提交于 2020-01-03 20:58:22
问题 In my app I have navigation drawer with some fragments. When I choose in the drawer I do this code: FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container, f, tag); ft.commit(); in the MainActivity. Now in one fragment I want to put a TabLayout in the bottom of the screen and I have this troubles: is it possible to replace from one fragment to another? Where could I put fragmentTransaction ? if I want to call a third fragment (for example a Send button in one of this tab

How to pass from one fragment to another

独自空忆成欢 提交于 2020-01-03 20:58:15
问题 In my app I have navigation drawer with some fragments. When I choose in the drawer I do this code: FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container, f, tag); ft.commit(); in the MainActivity. Now in one fragment I want to put a TabLayout in the bottom of the screen and I have this troubles: is it possible to replace from one fragment to another? Where could I put fragmentTransaction ? if I want to call a third fragment (for example a Send button in one of this tab

Android - Making translations and objectAnimator on the same XML file

江枫思渺然 提交于 2019-12-29 06:20:07
问题 I've been trying to make a 3D Cube rotation effect while sliding from one fragment to another. First i was using a translate effect (on XML) calling with FragmentTransaction.setCustomAnimations(...) and then, when opening/closing the fragment, i was playing with the Camera classe to make the rotation. This was working FINE, but seems that I HAVE TOO (don't ask me why) use all of this animation using only XML file. After a long search i found out that i should use objectAnimator to make the

Android - Making translations and objectAnimator on the same XML file

非 Y 不嫁゛ 提交于 2019-12-29 06:18:12
问题 I've been trying to make a 3D Cube rotation effect while sliding from one fragment to another. First i was using a translate effect (on XML) calling with FragmentTransaction.setCustomAnimations(...) and then, when opening/closing the fragment, i was playing with the Camera classe to make the rotation. This was working FINE, but seems that I HAVE TOO (don't ask me why) use all of this animation using only XML file. After a long search i found out that i should use objectAnimator to make the

Show a fragment with shared elements animation

纵然是瞬间 提交于 2019-12-22 10:07:56
问题 In my app I have code like this: final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, fragment, "tag"); transaction.addSharedElement(view, "transitionName"); transaction.addToBackStack(null) .commit(); It works fine, shared elements animation works. But if I change this code like getSupportFragmentManager().beginTransaction() .add(R.id.fragment_container, fragment, "tag") .hide(fragment) .commit(); final

How to add/remove Fragment on Button click?

为君一笑 提交于 2019-12-21 04:34:26
问题 At present I have got a "RELATIVE_LAYOUT" container which I am using for adding my fragment. I am using OnClickListener on a button to load the fragment XML layout into the RelativeLayout container. What I want to achieve is that when I press the button once, the fragment should load...and when I press it again the fragment should be removed. I've already tried using integer to identify if fragment is loaded, but failed. Any help Appreciated... CODE: public class MainActivity extends Activity

Fragment's Transaction replace on API-21 is staying behind

老子叫甜甜 提交于 2019-12-19 19:55:03
问题 I am developing an app that uses fragments, last week my test device took lolipop update. When I test my app on a lolipop device, I saw that Fragment Transaction's replace method didn't work properly. It work with confusingly in Lolipop version although everything fine on Kitkat version. In order to explain my situation, I've added some images. --First Screen----------------------------KitKat-------------------------------------Lollipop------------- As you can see, when i use kitkat ,

What to determine a Fragment restore upon Activity re-create?

社会主义新天地 提交于 2019-12-19 11:59:17
问题 For View s having IDs, they will be auto-saved when calling super.onSaveInstanceState(outState); . For Fragment s added to an Activity , what are the cases that it will be re-created when its Activity is re-created (e.g. screen rotation), and what are the cases it will not? What to determine? What is the rule? So far, i have tried the following cases. But trial-n-error does not mean any rules or solutions. Cases when Fragment s are re-stored: Normal case: FragmentTransaction.add() to the