Pass a value from one tab to another

0

I have two tabs in an Android application. One of them loads a list and the other positions me the items in this list. From tab2 I want to access the list of tab1. How can I do it?

Definition of tabs:

tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator(getString    
(R.string.label_listado)),ListFragment.class, null);

 tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator(getString  
 (R.string.label_geoposionar),getResources().getDrawable  
 (android.R.drawable.ic_dialog_map)),MapsFragment.class, null);

I tried to do the following:

MapsFragment ClaseMapa=new  MapsFragment();
ClaseMapa.newInstance(listado);

However, it does not work for me, how could I do it?

    
asked by adamista 26.04.2016 в 21:48
source

1 answer

2

You can create the variable of type list in the activity where you execute the fragments transaction and you can access the value of that list from the fragment

((MainActivity)getActivity()).lista;
    
answered by 27.04.2016 в 01:38