【问题标题】:Facebook slide Menu With MapView on Android在 Android 上使用 MapView 的 Facebook 幻灯片菜单
【发布时间】:2012-05-11 14:07:41
【问题描述】:

所以我知道有一些解决方法可以在我的 android 应用程序上获取 facebook 幻灯片菜单,可以通过以下任一方式:

1- FrameLayouts (http://stackoverflow.com/a/8673805/1010114)

2- 屏幕截图 (http://stackoverflow.com/a/9768498/1010114)

但是,我想要做的,到目前为止对如何实现一无所知,就是在 MapActivity 中拥有 facebook 幻灯片菜单。这样,用户可以看到 MapView 并与之交互,并且能够按菜单按钮查看菜单(当菜单出现时,用户不能与地图的可见部分交互也可以)

使用选项 2(截图)不起作用,因为我似乎不能不截取地图视图的屏幕截图(或者至少我不能使用他的方式)

关于如何做到这一点的任何提示/想法?

【问题讨论】:

    标签: android android-mapview mapactivity


    【解决方案1】:

    我遇到了同样的问题,并通过在 Activity 上添加 TabHost 解决了它。您可以将 MapActivity 设置为选项卡内容并为其隐藏按钮。

    示例代码:

    ma​​p.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <com.google.android.maps.MapView
            android:id="@+id/mapview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:clickable="true" />
    
    </LinearLayout>
    

    ma​​in.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    
        <Button
            android:id="@+id/menu_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="menu" />
    
        <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
    
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
            </FrameLayout>
        </TabHost>
    
    </LinearLayout>
    

    MyMapActivity.java:

    public class MyMapActivity extends MapActivity
    {
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.map);
        }
    }
    

    MyActivity.java:

    public class MyActivity extends TabActivity
    {
        private LayoutInflater inflater;
    
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
    
            inflater = LayoutInflater.from(context);
            // Inflate menu here
    
            // Get the TabHost
            TabHost tabHost = getTabHost();
    
            // Add the button and content
            TabHost.TabSpec spec = tabHost.newTabSpec("myMapTab")
                    .setIndicator("Map")
                    .setContent(new Intent(this, MyMapActivity.class));
            tabHost.addTab(spec);
    
            // Hide the button
            tabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE);
    
            MapView mapView = (MapView) tabHost.getTabContentView().getChildAt(0).findViewById(R.id.mapview)
        }
    }
    

    我希望这能解决你的问题。

    【讨论】:

    • 感谢您的代码。但是,这将如何帮助部署 facebook 幻灯片菜单功能?
    • 第一个示例包含一个指向 github 的链接,该链接向您展示了如何使用您的布局文件对其进行扩充。
    • 我一直在尝试给菜单充气。你能告诉我怎么做吗?
    • 你卡在哪里了?抱歉回复晚了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 2013-12-31
    • 2012-07-04
    • 1970-01-01
    • 1970-01-01
    • 2015-09-29
    • 2011-12-09
    相关资源
    最近更新 更多