I have 2 fragments: (1)Frag1 (2)Frag2.
bundl = new Bundle(); bundl.putStringArrayList("elist", eList); Frag2 dv = new Frag2(); dv.setArguments(bundl); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.the_fragg,dv); ft.show(getFragmentManager().findFragmentById(R.id.the_fragg)); ft.addToBackStack(null); ft.commit();
How do I get this data in Frag2?
Just call getArguments()
in your Frag2
's onCreateView()
method:
public class Frag2 extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup containerObject, Bundle savedInstanceState){ //here is your arguments Bundle bundle=getArguments(); //here is your list array String[] myStrings=bundle.getStringArray("elist"); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With