2

googleMap を表示/非表示にしたい。

GoogleMap  googleMap = ((SupportMapFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.map2)).getMap();

setVisibility(View.INVISIBLE) または setVisibility(View.VISIBLE)を設定する方法 ??

4

2 に答える 2

10

フラグメント自体を非表示にするか、サブクラスgetView().setVisibility(View.INVISIBLE)内で試すことができます。SupportMapFragment

アクティビティから:

FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction()
ft.hide(mFragment).commit();
于 2013-06-05T09:49:37.047 に答える
0

マップの表示/非表示を切り替えるトグル ボタンを実装しました。ブール値を単純に使用して監視し、マップを含む RelativeLayout で show/hide が呼び出されました。

XMLは--

<RelativeLayout
        android:id="@+id/map_container"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
<FrameLayout
            android:id="@+id/frame_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"


            <fragment
                android:id="@+id/map"
                android:layout_width="fill_parent"
                android:layout_height="match_parent" 
                class="com.google.android.gms.maps.SupportMapFragment"/>

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/transparent" />
        </FrameLayout>
</RelativeLayout>

あなたのJavaコードで--

//use a boolean map_shown and RL name is map_holder
if(map_shown){
map_holder.setVisibility(1);
}
else
{
map_holder.setVisibility(View.GONE);
}
于 2013-06-05T09:58:23.247 に答える