我有我的FragmentActivity
扩展ActionBar.TabListener
有两个选项卡。在带有标签的onCreateView()中使用Google Map Fragment
在我的第一个标签中,我试图显示GoogleMap
。
我该如何在我的onCreateView()
方法中做到这一点?这是我的代码:
public class MapFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_map, container, false);
this.ctx = container.getContext();
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
return rootView;
}
}
此代码让我对getMap()
的errore:
方法的GetMap()是未定义的类型MapFragment
这是我的XML布局fragment_map .xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
检查此链接https://forums.xamarin.com/discussion/15320/google-maps-actionbar-tabs –
更改您的类名'MapFragment'是别的 – Xcihnegn
您可以编辑您的问题,并张贴的XML你'MapFragment'? – shkschneider