【发布时间】:2015-01-23 20:06:56
【问题描述】:
我在我的 Android 应用程序中获得了一个带有两个 FrameLayouts 的 Activity。我想使用 googlemaps v2 在顶部框架布局中包含地图。在底部框架布局中,我想实现一个列表。每次我在地图中添加片段时,地图都会使用完整的屏幕,如果我在第二个框架布局中包含一个列表,我会收到一个空指针错误。
这是我如何在地图中包含片段的代码:
setContentView(R.layout.activity_new_tour);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
GoogleMapsFragment googleMapFragment = new GoogleMapsFragment();
ft.replace(R.id.fragment111_container,
googleMapFragment,"mapfragment");
ft.addToBackStack(null);
ft.commit();:
这是活动的布局
<FrameLayout
android:id="@+id/fragment111_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="40"
/>
<FrameLayout
android:id="@+id/fragment222_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="60" />
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="270dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@color/white"
android:dividerHeight="1dp"
android:listSelector="@color/blue"
android:background="@color/black"/>
</android.support.v4.widget.DrawerLayout>
谁能告诉我这是否可行,我该怎么做?也许有人可以给我举个例子。
【问题讨论】:
-
问题是什么?
标签: android google-maps android-fragments google-maps-api-3