为了账号安全,请及时绑定邮箱和手机立即绑定

片段中的MapView(Honeycomb)

片段中的MapView(Honeycomb)

DIEA 2019-08-15 16:34:47
片段中的MapView(Honeycomb)既然最终的SDK已经推出google apis - 使用MapView创建片段的最佳方法是什么?MapView需要MapActivity才能正常工作。让管理片段的Activity继承自MapActivity(糟糕的解决方案,因为它违背了Fragments自包含的想法)并使用常规的基于xml的布局不起作用。我在MapActivity.setupMapView()中得到一个NullPointerException:E / AndroidRuntime(597):引起:java.lang.NullPointerExceptionE / AndroidRuntime(597):在com.google.android.maps.MapActivity.setupMapView(MapActivity.java:400)E / AndroidRuntime(597):在com.google.android.maps.MapView。(MapView.java:289)E / AndroidRuntime(597):在com.google.android.maps.MapView。(MapView.java:264)E / AndroidRuntime(597):在com.google.android.maps.MapView。(MapView.java:247)我的第二个想法是以编程方式创建MapView并将关联的活动(通过getActivity())作为Context传递给MapView构造函数。不起作用:E / AndroidRuntime(834):引起:java.lang.IllegalArgumentException:MapViews只能在MapActivity的实例中创建。E / AndroidRuntime(834):在com.google.android.maps.MapView。(MapView.java:291)E / AndroidRuntime(834):在com.google.android.maps.MapView。(MapView.java:235)E / AndroidRuntime(834):at de.foo.FinderMapFragment.onCreateView(FinderMapFragment.java:225)E / AndroidRuntime(834):在android.app.FragmentManagerImpl.moveToState(FragmentManager.java:708)E / AndroidRuntime(834):在android.app.FragmentManagerImpl.moveToState(FragmentManager.java:900)E / AndroidRuntime(834):在android.app.FragmentManagerImpl.addFragment(FragmentManager.java:978)E / AndroidRuntime(834):在android.app.Activity.onCreateView(Activity.java:4090)E / AndroidRuntime(834):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:664)真的应该有类似MapFragment的东西来处理MapView需要的后台线程我猜...那么目前最好的做法是什么呢?
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 272 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信