0

Let's say I have fragment A in my current view. I animate myView in onCreateView method. Then I commit another fragment (fragment B) on top of fragment stack. When I go back to fragment A, myView animation is again started which I don't want it to. I think I should move the animation part to some other method. Would you please help?

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    ...
    animate myView;
    ...

    someOtherView.setOnClickListener(new View.OnClickListener() {

        @Override
        public boolean onClick(View v, MotionEvent event) {
         getActivity().getSupportFragmentManager().beginTransaction()
                            .addToBackStack(null)
                            .replace(R.id.framelayout_home,new Fragment_B()).commit();
        }
    });

    return rootView;
}
Tenten Ponce
  • 2,436
  • 1
  • 13
  • 40
Iman Norouzi
  • 11
  • 1
  • 6

1 Answers1

0

When you get back from fragment B just get the instance of fragment A and do your need. Reference https://stackoverflow.com/a/9295085/9252060