Android在片段中渲染Google Map

Android在片段中渲染Google Map,第1张

概述如上所示,我有一个片段活动,可以产生两个片段.在地图片段我想要实现并显示地图.由于我们需要扩展MapActivity,我不确定它是如何在片段内完成的.试图实现解决方案(https://stackoverflow.com/a/10739200/1737771)packagecom.m7.nomad;importandroid.app.LocalActivityManag

如上所示,我有一个片段活动,可以产生两个片段.在地图片段我想要实现并显示地图.

由于我们需要扩展MapActivity,我不确定它是如何在片段内完成的.

试图实现解决方案
(https://stackoverflow.com/a/10739200/1737771)

package com.m7.nomad;import androID.app.LocalActivityManager;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.LayoutInflater;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import com.actionbarsherlock.app.SherlockFragment;import com.actionbarsherlock.vIEw.Window;public class MapsFragment extends SherlockFragment {    private static final String KEY_STATE_BUNDLE = "localActivityManagerState";    private LocalActivityManager mLocalActivityManager;    protected LocalActivityManager getLocalActivityManager() {        return mLocalActivityManager;    }    @OverrIDe    public voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Bundle state = null;        if (savedInstanceState != null) {            state = savedInstanceState.getBundle(KEY_STATE_BUNDLE);        }        mLocalActivityManager = new LocalActivityManager(getActivity(), true);        mLocalActivityManager.dispatchCreate(state);    }    @OverrIDe    public VIEw onCreateVIEw(LayoutInflater inflater, VIEwGroup container,            Bundle savedInstanceState) {        // This is where you specify you activity class        Intent i = new Intent(getActivity(), GMapActivity.class);        Window w = mLocalActivityManager.startActivity("tag", i);        VIEw currentVIEw = w.getDecorVIEw();        currentVIEw.setVisibility(VIEw.VISIBLE);        currentVIEw.setFocusableIntouchMode(true);        ((VIEwGroup) currentVIEw)                .setDescendantFocusability(VIEwGroup.FOCUS_AFTER_DESCENDANTS);        return currentVIEw;    }    @OverrIDe    public voID onSaveInstanceState(Bundle outState) {        super.onSaveInstanceState(outState);        outState.putBundle(KEY_STATE_BUNDLE,                mLocalActivityManager.saveInstanceState());    }    @OverrIDe    public voID onResume() {        super.onResume();        mLocalActivityManager.dispatchResume();    }    @OverrIDe    public voID onPause() {        super.onPause();        mLocalActivityManager.dispatchPause(getActivity().isFinishing());    }    @OverrIDe    public voID onStop() {        super.onStop();        mLocalActivityManager.dispatchStop();    }    @OverrIDe    public voID onDestroy() {        super.onDestroy();        mLocalActivityManager.dispatchDestroy(getActivity().isFinishing());    }}

我应该为近处指定什么

..............public VIEw onCreateVIEw(LayoutInflater inflater, VIEwGroup container,            Bundle savedInstanceState) {        // This is where you specify you activity class        Intent i = new Intent(getActivity(), GMapActivity.class);        Window w = mLocalActivityManager.startActivity("tag", i);..................

解决方法:

看一下刚刚发布的新Google Maps Android API v2.它包含对片段(包括支持库)的支持等等.

总结

以上是内存溢出为你收集整理的Android在片段中渲染Google Map全部内容,希望文章能够帮你解决Android在片段中渲染Google Map所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1099194.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存