android - 以编程方式设置谷歌地图 fragment 可见性(API2)

标签 android google-maps android-fragments visibility

xml:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/mapFragment"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  class="com.google.android.gms.maps.SupportMapFragment"/>

在常规 fragment 中是这样的:

  mFragment = (mFragment) (getSupportFragmentManager().findFragmentById(R.id.mFragment));
  mFragment.getView().setVisibility(View.INVISIBLE);

在谷歌地图 fragment 中:

  mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapFragment)).getMap();

但我怎样才能逐步设置 map fragment 的可见性?

不能像其他 fragment 那样做。

最佳答案

就这么简单:

private GoogleMap mMap;
private SupportMapFragment mMapFragment;

mMapFragment = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.mapFragment));
mMap = mMapFragment.getMap();

mMapFragment.getView().setVisibility(View.INVISIBLE);

关于android - 以编程方式设置谷歌地图 fragment 可见性(API2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13833709/

相关文章:

android - Facebook SDK 2.0 能运行多长时间

android - 在 eclipce 中打开 XML 文件时出现 StackOverflowError

java - 错误 : com. jayway.maven.plugins.android.generation2 :android-maven-plugin:3. 6.0:generate-sources

android - 如何找到特定路线上两点之间的距离?

javascript - Google map 未正确填充 div

android - 添加 fragment 时从汉堡包到箭头图标的过渡动画

android - 重新创建 fragment - 查看寻呼机 - FragmentPagerAdapter

android - AdBlock 网页 View ?

javascript - 如何通过输入城市/城镇名称从谷歌地图获取餐厅列表?

android - 弹出最后一个 fragment 时处理返回键