【问题标题】:Google Maps in Android: Failed to find style 'mapViewStyle' in current themeAndroid 中的 Google 地图:无法在当前主题中找到样式“mapViewStyle”
【发布时间】:2012-05-25 23:00:33
【问题描述】:

对不起,伙计们,关于这个话题的另一个人。到目前为止,我已经阅读了所有关于它的帖子,但到目前为止,没有一个答案适合我。我已经花了几个小时试图解决这个问题,在开始拔毛之前,我想在这里再试一次。

在 XML 布局和图形布局之间切换时,我在 Eclipse 中收到上述错误消息。

Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
Failed to find style 'mapViewStyle' in current theme

这是我的布局 XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<!-- Screen Design for the MAP Tab -->
<TextView
    android:id="@+id/vvm_offline"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="15dip"
    android:text="You have to be online to display the map."
    android:textSize="18dip" />

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:apiKey="xxx"
    android:clickable="true"
    android:state_enabled="true" />

<LinearLayout
    android:id="@+id/zoom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</LinearLayout>

在我的 AndroidManifest.xml 中,根据我发现的其他提示,一切似乎都应如此:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.myapp"
android:versionCode="1"
android:versionName="0.1" >
<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:label="@string/app_name" >
    <uses-library
        android:name="com.google.android.maps"
        android:required="true" />

    <activity
        android:name=".myappActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
    (etc.)

    <activity
        android:name=".ViewMapActivity"
        android:label="View Map" >
    </activity>
    (etc.)

顺便说一句,我是否在 android:theme 中定义了“主题”并没有区别。

任何想法如何解决这个错误?我可以编译并运行应用程序,但在创建视图时会收到 NullPointerException。

【问题讨论】:

  • 仅供参考,一个帖子脚本:在这浪费了很多小时之后,似乎没有解决方案。问题是:尽管错误消息显示在图形布局编辑器中,但代码编译得很好,程序也能按预期工作。因此,在我了解 Android 开发者希望我们如何做之前,我只会忍受这个尴尬的错误消息并继续前进。

标签: android google-maps android-layout


【解决方案1】:

这也发生在我身上。进入 res>values>styles.xml

去掉之前的主题行,放上这一行

<style name="AppBaseTheme" parent="android:Theme.Light">

项目创建期间的 Eclipse 要求为应用程序定义一个主题。您可能选择了任何Holo theme。此主题不支持显示错误的MapView

【讨论】:

    猜你喜欢
    • 2011-10-21
    • 2012-03-16
    • 2012-01-20
    • 2011-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    相关资源
    最近更新 更多