我有我的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