让我们解决"当前主题中找不到风格'mapViewstyle'的错误"

Bil*_*ldr 21 eclipse android android-layout android-mapview

很抱歉发布另外一个,但似乎我们还没有记录这个问题的每个解决方案.

这是发生了什么:我添加了mapview,一切都在工作.我添加了一个滑动抽屉并将按钮移入其中,然后将根节点从线性更改为相对.从那时起,我在读取的main.xml类的图形布局中出现错误

缺少风格.是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用.无法在当前主题中找到样式'mapViewStyle'.

将根节点切换为线性并返回到相对位置已使地图显示,但错误仍在图形布局中.

到目前为止,我已经完成了以下解决方案,可以解决大多数情况下的问题:

  1. 添加了style.xml以创建"mapView"样式.
  2. 验证我的构建目标是API 2.3.3(10)
  3. 确保<uses-library android:name="com.google.android.maps"/>是Application的子节点.
  4. 清理/重建我的应用程序.
  5. 删除了R.
  6. 删除并重建了main.xml
  7. 重新启动了adb服务器,Eclipse,我的计算机和我的设备.
  8. 在图形布局中,在Android 3.0和Android 2.3.3之间切换.

但是,我的问题仍然存在.这是我的布局xml.

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


<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    style="@style/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:apiKey="asdf" //not my real key
    android:clickable="true" />

<!-- TODO: update the API key with release signature -->
<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:content="@+id/content"
    android:handle="@+id/handle" >

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Menu" />


    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/about"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/about" />

        <Button
            android:id="@+id/record"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/record" />

        <Button
            android:id="@+id/start"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/start" />

    </LinearLayout>

</SlidingDrawer>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的清单xml.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.myschoolhere"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <uses-library android:name="com.google.android.maps"/>
    <activity
        android:name=".GeoTagActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

如果有人有解决方案,请告诉我.如果我弄清楚的话,我会尽力回复.

Kar*_*amy 10

我的答案可能是迟到的,但我希望它能解决实际原因,并确保它可能对那些将来会搜索同一问题的人有所帮助.

这种错误,

1. Android Google Maps Failed to find style 'mapViewStyle' in current theme
2. Failed to find style 'imageButtonStyle' in current theme 
3. Failed to find style 'editTextStyle' in current theme 
4. Failed to find style 'textViewStyle' in current theme 
Run Code Online (Sandbox Code Playgroud)

它可能是以上列表中的任何内容,

最终的原因是,

我们选择了不可用Themelayout.

这可能是因为,

  1. 所选theme内容在themes.xml文件中不可用.
  2. 所选theme的属于更高版本sdk,但我们当前的目标sdk是较低的版本.

这个问题大多发生,

  1. 当你复制整个layout文件并尝试在你的文件中实现它project.一个.您可能忘记复制themes.xml文件b.您可能有较低的target sdk,原始layout创建更高target sdk.

这个问题的解决方案是,

(打开查看layout在文件中Graphical Layout View,并期待在右上角有你themeslayout已经被选中.)

  1. 所以点击下拉列表theme选项,并选择可用的themes根据项目themestargeted sdk themes. (要么)
  2. 如果themecustom一个,如果您需要它,则将themes.xml文件从您复制layout xml文件的源复制到项目中. (要么)
  3. 如果themesdk无济于事theme,如果你需要它,那么你改变target根据您的选择theme.

希望,这可能对某人有帮助.

  • 这是您答案的精确副本http://stackoverflow.com/questions/8513278/android-failed-to-find-style-mapviewstyle-in-current-theme.此问题与themes.xml无关,因为该主题继承自Maps API. (3认同)

归档时间:

查看次数:

30565 次

最近记录:

8 年,8 月 前