The first activity contains a Fragment, and there's a button inside the fragment, and when I click this button, I wish to jump to a new Activity with different animation. So I do it like this in the Fragment:
mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), NewActivity.class);
getActivity().startActivity(intent);
getActivity().overridePendingTransition(
R.anim.forward_activity_move_in,
R.anim.forward_activity_move_out);
});
However the new animation does not take effect when moves to the new Activity, so I wonder maybe I do it wrong. I hope someone can help me, thx a lot:)
When we press the FAB (Floating Action Button) button,we open the MyFragment via Fragment Transaction,attaching it to a FrameLayout we shall define. The Fragment contains an edittext and a spinner. User types the spacecraft name and chooses the launch year in the spinner. We then pass both these data back to MainActivity.
Internally, the FragmentManager implementations iterates over a list and stops at the first occurrence of a fragment having such id. Now remember, “ A ” was added, removed. Hence the first and only occurrence here would be “ C “.
Others have tried to perform a popBackstack just before adding their own new fragment (causing a glitch on the monitor) The only solution i’ve found to work properly is to always add the transactions to the backstack and handle such “ A -> B -> C (back) -> A ” behavior by myself. For this reason i created a snippet that seems to work properly.
Even though activities and fragments are nothing but classes, they are considered special classes in android since they are fundamental to how android User interface works. Thus we don’t just pass them data via constructors but in one of the following three ways: We will look at all these using practical examples in this lesson. Let’s start.
Thanks, I solved this problem, You can find solutions at Change activity transition when inside a TabHost
Well the problem is not the case of Fragment, instead the TabActivity causes the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With