android - Navigation Drawer and MapFragment -


I want to know what is the right approach to implementing mapping with a navigation drawer I already have this work Was doing fine, but I'm reading some documents and maybe it can cause problems in the future.

Then, my main square where the navigation drawer has been implemented, it is very common the following selectItem () method:

  the home activity activity Enhances {// ... // content like purchases (), etc. // ... Private Zero SelectItem {if position (position == 0) {// position 0 navigation drawer piece piece = new mapframement () is the mapped option; Piece Manager Piece Manager = getFragmentManager (); FragmentManager.beginTransaction () .replace (R.id.content_frame, fragment) .commit (); } MDrawerList.setItemChecked (status, true); SetTitle (listaElementosDrawer [status]); MDrawerLayout.closeDrawer (mDrawerList); }}  

Mapfragment, which is a fragmented piece of main activity, is as follows:

  the public class spreads the Mapfraggment fragment {public mapfragment () {} @ Override Public View Creatives (LayoutInflator Inflator, View Group Container, Bundle Saved InstantState) {see Routview = Inflator.In Flat (R. Late Fragmentmap, Container, Falls); Return root view; }}  

and, fragment_map.xml which is blown into MapaFragment , such as:

 < Code> & lt; Relative layout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: Layout_height = "Match_parent" tool: reference = "com.moictab.decanias.MapActivity $ placeholder fragment" & gt; & Lt; Fragment android: id = "@ + id / map" Android: layout_width = "match_parent" Android: layout_height = "match_parent" class = "com.google.android.gms.maps.MapFragment" /> & Lt; / RelativeLayout & gt;  

Note that this is a map fragment inside a relative layout, and it is already working well. But, if I remove the relational layout and leave the macrofragment, then it causes accidents because I am raising a piece inside a piece. So, the question is:

  • Why does this crash when this map inflows the phrase, but does not crash at that time when the relational layout has to be expanded inside the mapframe? Is not this essentially the same?
  • What is the right approach to do something like this?
  • I had a very similar problem with MapFragment. This is my solution:

    I extend the SupportMapFragment object:

      increases the public class MyMapFragment SupportMapFramgment {}  

    And add it programmatically:

      MyMapFragment fragment = new MyMapFragment (); Replace fragmentManager.beginTransaction () (R.id.content_frame, slice) .commit () .;  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -