Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Collapsebutton_Fragment extends Fragment {
- Collapsebutton_Fragment cpb_fragment;
- Animation_Fragment anim_fragment;
- FragmentManager fragmentManager;
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.collapsebutton_fragment, container, false);
- //Look for an animation xml file with a good collapse animation
- final Animation collapse = AnimationUtils.loadAnimation(getActivity(),R.anim.collapse_animation);
- final Button button = (Button)rootView.findViewById(R.id.CollapseButton);
- cpb_fragment = new Collapsebutton_Fragment();
- anim_fragment = new Animation_Fragment();
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- v.startAnimation(collapse);
- //wait for a certain time, then remove the button and start animation
- //remove is not functioning, why not?
- getFragmentManager().beginTransaction()
- .remove(getFragmentManager().findFragmentById(R.id.CollapseButton))
- .commit();
- //does not wait until the animation is finished
- getFragmentManager().beginTransaction()
- .add(R.id.container_mainactivity,anim_fragment)
- .addToBackStack(null)
- .commit();
- }
- });
- return rootView;
- }
- }
Add Comment
Please, Sign In to add comment