0

だから私は私のAndroidアプリでFacebookのスライドメニューを取得するためのいくつかの回避策を知っています。これは次のいずれかを介して行うことができます。

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

2-スクリーンショット(http://stackoverflow.com/a/9768498/1010114)

しかし、私がやりたいこと、そしてこれまでのところ達成方法がわからないのは、FacebookのスライドメニューをMapActivityに含めることです。このようにして、ユーザーはMapViewを表示および操作でき、メニューボタンを押してメニューを表示できます(メニューが表示されたときに、ユーザーがマップの表示部分を操作できない場合でも問題ありません)。

オプション番号2(スクリーンショット)の使用は、マップビューのスクリーンショットを撮ることができないように見えるため(または少なくとも彼の方法を使用できないため)機能しませんでした

それを行う方法に関するヒント/アイデアはありますか?

4

1 に答える 1

0

同じ問題があり、アクティビティに TabHost を追加して解決しました。MapActivity をタブ コンテンツとして設定し、そのボタンを非表示にすることができます。

コード例:

マップ.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>

main.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)
    }
}

これで問題が解決することを願っています。

于 2012-05-11T15:19:22.300 に答える