无法在android studio Gradle中编译项目:无效符号:’switch’

我正在使用 Android studio来编译项目. Project min SDK为14,目标为17.

我正在使用此代码.

<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"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">


        <Switch
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Switch"
            android:id="@+id/switch" android:layout_alignBottom="@+id/button3" android:layout_toRightOf="@+id/button3"
            android:layout_marginLeft="44dp"/>


</RelativeLayout>

解决方法

如果您将交换机的ID更改为“@ id / switch”以外的其他内容,则可以解决此错误.例如:
<Switch
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Switch"
            android:id="@+id/Switch"
            android:layout_below="@+id/Switch"
            android:layout_alignLeft="@+id/Switch"/>

将是一个有效的开关.

来源:https://code.google.com/p/android/issues/detail?id=55720

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...