Guest User

Untitled

a guest
Jun 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. public class Collapsebutton_Fragment extends Fragment {
  2.  
  3. Collapsebutton_Fragment cpb_fragment;
  4. Animation_Fragment anim_fragment;
  5. FragmentManager fragmentManager;
  6.  
  7. @Nullable
  8. @Override
  9. public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  10.  
  11. View rootView = inflater.inflate(R.layout.collapsebutton_fragment, container, false);
  12.  
  13. //Look for an animation xml file with a good collapse animation
  14. final Animation collapse = AnimationUtils.loadAnimation(getActivity(),R.anim.collapse_animation);
  15. final Button button = (Button)rootView.findViewById(R.id.CollapseButton);
  16. cpb_fragment = new Collapsebutton_Fragment();
  17. anim_fragment = new Animation_Fragment();
  18.  
  19. button.setOnClickListener(new View.OnClickListener() {
  20. @Override
  21. public void onClick(View v) {
  22. v.startAnimation(collapse);
  23.  
  24. //wait for a certain time, then remove the button and start animation
  25. //remove is not functioning, why not?
  26. getFragmentManager().beginTransaction()
  27. .remove(getFragmentManager().findFragmentById(R.id.CollapseButton))
  28. .commit();
  29.  
  30. //does not wait until the animation is finished
  31. getFragmentManager().beginTransaction()
  32. .add(R.id.container_mainactivity,anim_fragment)
  33. .addToBackStack(null)
  34. .commit();
  35. }
  36. });
  37.  
  38. return rootView;
  39. }
  40. }
Add Comment
Please, Sign In to add comment