Skip to content Skip to sidebar Skip to footer

Based On String Array Item, Show Same Item To Next Fragment

I have two fragments ListNav and SwipeNav in Navigation Drawer. ListNav shows list view of data from String array. SwipeNav shows data as swipe views of the same data from string a

Solution 1:

I thing you are missing one step there and that is you need to send data in String form when swipe fragment is replacing . Like.

Bundlebundle=newBundle();
bundle.putString("TAG", "D");
// set Fragmentclass ArgumentsSwipeNavfragobj=newSwipeNav();
fragobj.setArguments(bundle);
  FragmentManager fm=getFragmentManager();
        FragmentTransactionft= fm.beginTransaction();
        ft.replace(((ViewGroup)(getView().getParent())).getId(), fragobj);
        ft.addToBackStack(null);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();

now on your swipe fragment make sure you are receiving that string that you are passing when creating . so in onCreateViewmethod .

@OverridepublicViewonCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    String passingString = getArguments().getString("TAG");    
    return inflater.inflate(R.layout.fragment, container, false);
}

Here TAG just identifying what you are passing .

Post a Comment for "Based On String Array Item, Show Same Item To Next Fragment"