我有框架布局,我在其中显示片段,我如何显示谷歌地图它的 frame_layout。我下一个:
- 获取 API 密钥
添加谷歌播放服务库但我得到nullPointerExeption,也许有人知道如何使用它的好例子?car_waches.xml
片段类:
public class FragmentCarWashes extends SherlockFragment {
View v;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
GoogleMap map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.mapFragment))
.getMap();
v = inflater.inflate(R.layout.fragment_car_washes, null);
return v;
}
}
清单文件
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<permission
android:name="com.example.cars51ru.permition.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.cars51ru.permition.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light" >
<meta-data
android:name="com.google.android.maps.v3.API_KEY"
android:value="api key" />
<activity
android:name="com.example.cars51ru.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.cars51ru.MainActivity"
android:label="@string/app_name" >
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>