I'm passing data from fragment to another fragment with a bundle, but I have a map and I want to update this fragment and non replace it...this is the code in the MainActivity:
Mapped map = new Mapped();
final Bundle bundle = new Bundle();
bundle.putString("Position",one);
bundle.putString("ID",two);
map.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.mapView, map).commit();
and every time it delete the old fragment...How can I do to update it and not replace?
EDIT: this is the code of MainActivity:
public class MainActivity extends FragmentActivity implements Connection.SendMessage
{
ViewPager Tab;
TabPagerAdapter TabAdapter;
ActionBar actionBar;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabAdapter = new TabPagerAdapter(getSupportFragmentManager());
Tab = (ViewPager)findViewById(R.id.pager);
Tab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
{
public void onPageSelected(int position)
{
actionBar = getActionBar();
actionBar.setSelectedNavigationItem(position);
}
});
Tab.setAdapter(TabAdapter);
actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.TabListener tabListener = new ActionBar.TabListener()
{
public void onTabReselected(android.app.ActionBar.Tab tab,FragmentTransaction ft)
{
}
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft)
{
Tab.setCurrentItem(tab.getPosition());
}
public void onTabUnselected(android.app.ActionBar.Tab tab,FragmentTransaction ft)
{
}};
actionBar.addTab(actionBar.newTab().setText("Connessione").setTabListener(tabListener));
actionBar.addTab(actionBar.newTab().setText("Mappa").setTabListener(tabListener));
}
public void send(String one, String two)
{
Mapped map = new Mapped();
final Bundle bundle = new Bundle();
bundle.putString("Position",one);
bundle.putString("ID",two);
map.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.mapView, map).commit();
}
}