Note that there are some explanatory texts on larger screens.

plurals
  1. POi can't switch fragments of googlemap fragment and other is just a listview
    primarykey
    data
    text
    <p>I'm trying the following code. I could not switch appropriately the fragments. By clicking on menuitem I replace the fragment. For the first time when I add the googlemap it is shown right but when I want to click again to view map, the map is not shown .Kindly help me out: Here i add the default fragment google map:</p> <pre><code>@Override public void onCreate(Bundle savedinstancestate) { super.onCreate(savedinstancestate); setContentView(R.layout.stores); Fragment map = new MapView(); getFragmentManager().beginTransaction().add(R.id.fragment_container, map).addToBackStack(null).commit(); } </code></pre> <p>Then i replace the fragments here: public void swapFragment(MenuItem item) { Fragment storelist = new StoreList(); switch (item.getItemId()) {</p> <pre><code> case R.id.StoreIcon: if(item.getTitle().equals("Storeicon")) { getFragmentManager().beginTransaction().replace(R.id.fragment_container, storelist).addToBackStack(null).commit(); item.setTitle("changed"); item.setIcon(R.drawable.store_map); } else { // getFragmentManager().popBackStack(); Fragment map = new MapView(); // getFragmentManager().beginTransaction().replace(R.id.fragment_container,map).addToBackStack(null).commit(); // getFragmentManager().beginTransaction().add(R.id.fragment_container,map).addToBackStack(null).commit(); item.setTitle("Storeicon"); item.setIcon(R.drawable.store_map); } default: Log.d("somethingother", ""); } } </code></pre> <p>these are the fragment classes:</p> <pre><code>public static class MapView extends Fragment{ @Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedinstancestate) { View view = null; try{ view = inflater.inflate(R.layout.map,container,false); } catch(Exception e) { e.getStackTrace(); } return view; } } public static class StoreList extends Fragment{ @Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedinstancestate) { return inflater.inflate(R.layout.store_list,container,false); } } </code></pre> <p>Fragment container: </p> <p> Kindly help me the googlemap is also fragment.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload