我目前正在做一个包含googlemap的应用程序。该xml文件的代码如下所示,但在图形布局中显示错误
“缺少样式。是否为此布局选择了正确的主题? 使用布局上方的主题组合框选择不同的布局,或修复主题样式引用。
无法在当前主题“
中找到样式'mapViewStyle'运行googlemap时,它会将logcat中的错误显示为
java.lang.RuntimeException:无法启动活动ComponentInfo {com.iqmobi / com.iqmobi.Map}:android.view.InflateException:二进制XML文件行#3:错误导致类com.google.android.maps。 MapView类
xml和manifest文件在下面给出
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/myMapView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0mRN-6bSm63hZJtPZSmcjoZAzdCztLnZv-O4SZw"
>
</com.google.android.maps.MapView>
</LinearLayout>
的manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iqmobi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="9"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="@drawable/iconffff"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
<activity
android:label="@string/app_name"
android:name="com.iqmobi.Map"
android:screenOrientation="portrait"
>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
答案 0 :(得分:0)
您需要将主类扩展为MapActivity
public class Abc extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
答案 1 :(得分:0)
将您的布局更改为RelativeLayout并删除此行</com.google.android.maps.MapView>
像这样,没有布局ID,像这样:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/myMapView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="api key" />
</RelativeLayout>