【发布时间】:2014-10-21 10:13:39
【问题描述】:
我已将 android SDK 更新到 5.0,但我之前的项目无法运行(在 4.4.2 中正常运行)。
我有一个扩展片段的类
public class MapFragment extends Fragment{
//
}
在这个课程中,我使用谷歌支持的 mapfragment 扩展了一个布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_tile_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" >
<RelativeLayout
android:id="@+id/full_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<Textview
<!-- dfh
fgh -->
/>
</RelativeLayout>
</RelativeLayout>
当我在我的代码中执行此操作时,它返回 null
SupportMapFragment fragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
这条线在 Android4.4.2 中对我有用,但更新后出现了一些问题......
有没有人找到解决办法...
【问题讨论】:
标签: android google-maps android-fragments supportmapfragment