Im facing a problem in fragments during animation... As im new to fragment concept im unable to get it.. The problem is....
1. I placed a fragment on the activity.
2. When i press on the button i set an animation to show another fragment
3. and i added addbackstack.
4. After that in Second fragment i kept a button in that if i press that button the fragment will be closed for this i used popbackstack.
5. Until this it was clear.
6. My problem is When i click on that button it should close with an animation for this i used this code
ft.setCustomAnimations(R.anim.slide_in_up,R.anim.slide_out_down, R.anim.slide_in_up,R.anim.slide_out_down);
7.But i was not showing the animation and simply closes.
8.I check the api version compatibility also but unable to find that mistake
Hope I have give sufficient information about my question and you guys have understood my problem.If i seems insufficient then please let me know that. Thank you
Here Im repalcing fragment! with fragment2 with animation:
icon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
FragmentTransaction ft = getFragmentManager()
.beginTransaction();
android.app.FragmentManager m=getActivity().getFragmentManager();
ft.setCustomAnimations(R.anim.slide_in_up,
R.anim.slide_out_down);
Fragment2 n2 = new Fragment2();
ft.replace(R.id.realtabcontent, n2);
ft.addToBackStack(null);
ft.commit();
});
Here Im closing fragment2 with animation:
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
android.app.FragmentManager m=getActivity().getFragmentManager();
FragmentTransaction ft = getActivity().getFragmentManager()
.beginTransaction();
m.popBackStack();
ft.setCustomAnimations(R.anim.slide_in_up,R.anim.slide_out_down, R.anim.slide_in_up,R.anim.slide_out_down);
ft.commit();
}
});
But here animation was not working for me...