我一直在处理这个问题一段时间了.我用这个问题作为参考:
Using ActionBarSherlock With the New SupportMapFragment
我目前正在使用ActionbarSherlock,我正在使用Vipul Shah相当简单的地图实现.它的工作非常出色,完全符合我的需要.但是,在OrIEntation更改时,整个应用程序崩溃.这是我的日志:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.meetball_1/com.meetball_1.HomeActivity}: androID.vIEw.InflateException: Binary XML file line #17: Error inflating class fragment at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2211) at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) at androID.app.ActivityThread.handle@R_319_4404@Activity(ActivityThread.java:3740) at androID.app.ActivityThread.access0(ActivityThread.java:141) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1262) at androID.os.Handler.dispatchMessage(Handler.java:99) at androID.os.Looper.loop(Looper.java:137) at androID.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: androID.vIEw.InflateException: Binary XML file line #17: Error inflating class fragment at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:713) at androID.vIEw.LayoutInflater.rInflate(LayoutInflater.java:755) at androID.vIEw.LayoutInflater.rInflate(LayoutInflater.java:758) at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:492) at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:397) at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:353) at com.androID.internal.policy.impl.PhoneWindow.setContentVIEw(PhoneWindow.java:267) at com.actionbarsherlock.internal.ActionbarSherlockNative.setContentVIEw(ActionbarSherlockNative.java:133) at com.actionbarsherlock.app.SherlockFragmentActivity.setContentVIEw(SherlockFragmentActivity.java:261) at com.meetball_1.HomeActivity.onCreate(HomeActivity.java:70) at androID.app.Activity.performCreate(Activity.java:5133) at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2175) ... 12 more Caused by: java.lang.IllegalStateException: Fragment com.Google.androID.gms.maps.SupportMapFragment dID not create a vIEw. at androID.support.v4.app.FragmentActivity.onCreateVIEw(FragmentActivity.java:303) at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:685) ... 24 more
我意识到,无论出于何种原因,视图都没有被创建,并且错误来自应用程序未能扩充我的类片段.我怎么解决这个问题而不会让事情变得太复杂,因为我觉得实现地图很简单所以应该是我的解决方案.这是我的xml片段:
<fragment androID:ID="@+ID/map" androID:layout_wIDth="fill_parent" androID:layout_height="230dp" androID:layout_weight="1" androID:layout_gravity="center_horizontal|top" />
这是我的相关代码段:
@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentVIEw(R.layout.activity_main); SupportMapFragment fragment = SupportMapFragment.newInstance(); getSupportFragmentManager().beginTransaction() .add(R.ID.map, fragment).commit();}
谢谢大家!
我此刻已经尝试了一切.这是Googlemap的错误吗?我如何解决它?
解决方法:
我有同样的问题并解决它,我不得不使用FrameLayout而不是片段:
<FrameLayout androID:ID="@+ID/mapvIEw" androID:name="com.Google.androID.gms.maps.SupportMapFragment" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" />
然后:
SupportMapFragment mMapFragment = (SupportMapFragment) getActivity() .getSupportFragmentManager().findFragmentByID(R.ID.mapvIEw); if (mMapFragment == null) { mMapFragment = SupportMapFragment.newInstance(); fm.beginTransaction().replace(R.ID.mapvIEw, mMapFragment).commit(); }
总结 以上是内存溢出为你收集整理的android – GoogleMap v2在方向更改时崩溃应用程序时遇到问题全部内容,希望文章能够帮你解决android – GoogleMap v2在方向更改时崩溃应用程序时遇到问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)