1

When I called another fragment, ViewPager of first fragment is not removed. I have spent 2 days on it but didn't get it. I will be very thankful if some one will help me.

FragmentManager fragmentManager = getFragmentManager();
        Fragment fragment=new SecondPage(urlToSecondPageStory,storyCategoryContainer.get(position));
        Bundle bundle = new Bundle();
        bundle.putString("imageurl",imageUrl);
        fragment.setArguments(bundle);
        FragmentTransaction transaction=fragmentManager.beginTransaction();
        transaction.replace(android.R.id.content,fragment);
    //  transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        //transaction.addToBackStack(null);
        transaction.commit();
Mike Laren
  • 7,768
  • 17
  • 48
  • 69
Bpatel
  • 77
  • 8

1 Answers1

0

check out Replacing ViewPager with Fragment - Then Navigating Back

Community
  • 1
  • 1
Andrea Cinesi
  • 406
  • 2
  • 10
  • Could you please elaborate more your answer adding a little more description about the solution you provide? – abarisone Jun 16 '15 at 07:23
  • i have two fragment class and In first fragment i define gridview in viewPager but when i click on gridview item i want that view pager should be remove and my another fragment should call. problem is that fragment has called but data of another fragment has set on viewpager of firstfragment. – Bpatel Jun 16 '15 at 07:33
  • so you have the second fragment open with the fragment 1 data in the viewpager? – Andrea Cinesi Jun 16 '15 at 07:35
  • on second fragment i am not calling view pager i have simple xml. on Which fragment i should call viewpager.setVisibility(View. GONE );? – Bpatel Jun 16 '15 at 07:38
  • when you click on gridview item you can try to do like i said in the answer inside the onClick, in the first fragment – Andrea Cinesi Jun 16 '15 at 07:39
  • i have define view pager in activity but i want to switch from fragment to fragment so i how to set view pager visibility..?? – Bpatel Jun 16 '15 at 07:47
  • try to add objects in second fragment layout, they are visible? – Andrea Cinesi Jun 16 '15 at 07:47
  • http://stackoverflow.com/questions/12490963/replacing-viewpager-with-fragment-then-navigating-back – Andrea Cinesi Jun 16 '15 at 07:55