Re: [android-developers] Re: Displaying Google Map Android API V2 in fragment
Hi VenomVendor,
I have do the same, which you have mentioned in above post.In LogCat, I have got successful log that my map get set with location and marker.
I am not getting that what is the problem ? :(
According to Harri, If I add fragmentManager.executePendingTransactions(); after commiting fragmentTransaction.
Then it throws exception:
java.lang.IllegalArgumentException: No view found for id 0x7f0601e7 (com.abcd:id/map) for fragment MapFragment{419b5f80 #0 id=0x7f0601e7}
java.lang.IllegalArgumentException: No view found for id 0x7f0601e7 (com.abcd:id/map) for fragment MapFragment{419b5f80 #0 id=0x7f0601e7}
On Sat, Dec 14, 2013 at 5:08 PM, VenomVendor™ <yoganandh2003@gmail.com> wrote:
Hi,
I have done same task, adding Map inside fragment, where fragment is placed inside ViewPager.
* <p>public class Map extends Fragment {
/** The view. */
private static View view;
/** The g map. */
private static GoogleMap gMap;
/** The bangalore. */
private final LatLng BANGALORE = new LatLng(12.971689, 77.594504);
/** The zoom. */
private float zoom = 11.0f;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (container == null) {
return null;
}
if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent();
if (parent != null)
parent.removeView(view);
}
try {
view = inflater.inflate(R.layout.map, container, false);
setUpMapIfNeeded();
} catch (InflateException e) {
// Log.wtf("S*****", e.getMessage());
}
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
gMap = null;
if (gMap != null)
setUpMap();
if (gMap == null) {
gMap = ((SupportMapFragment) this.getActivity().getSupportFragmentManager()
.findFragmentById(R.id.mapd)).getMap();
if (gMap != null)
setUpMap();
}
}
/***** Sets up the map if it is possible to do so *****/
public void setUpMapIfNeeded() {
if (gMap == null) {
gMap = ((SupportMapFragment) getActivity().getSupportFragmentManager()
.findFragmentById(R.id.mapd)).getMap();
if (gMap != null)
setUpMap();
}
}
/**
* This is where we can add markers or lines, add listeners or move the
* camera.
* This should only be called once and when we are sure that {@link #gMap}
* is not null.
*/
private void setUpMap() {
gMap.addMarker(new MarkerOptions().position(BANGALORE).title("My Home")
.snippet("Home Address"));
gMap.animateCamera(CameraUpdateFactory.newLatLngZoom(BANGALORE, zoom));
}
/****
* The mapfragment's id must be removed from the FragmentManager or else if
* the same it is passed on the next time then app will crash
****/
// @Override
// public void onDestroyView() {
// super.onDestroyView();
// FragmentManager fm = getActivity().getSupportFragmentManager();
// Fragment fragment = (fm.findFragmentById(R.id.mapd));
// FragmentTransaction ft = fm.beginTransaction();
// ft.remove(fragment);
// ft.commit();
// }
}
On Thursday, 5 December 2013 14:04:28 UTC+5:30, surabhi jain wrote:I have 3 pager (Fragment), all 3 fragments will showing map.I have created Map dynamically using SupportMapFragment.I am using ViewPager, inside that I have created my layout and also displaying map.Hi All,I have problem in showing Google map (API V2) in fragment.
When I switch to 1st fragment to 2nd fragment at that time map is not displaying in my 2nd fragment layout. Showing black screen..... :(
--Thanks & RegardsSurabhi Jain--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
Thanks & Regards
Surabhi JainYou received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home