【问题标题】:Unable to compile project in android studio Gradle: invalid symbol: 'switch'无法在 android studio Gradle 中编译项目:无效符号:'switch'
【发布时间】:2013-05-19 15:41:56
【问题描述】:

我正在使用 Android Studio 来编译项目。项目最小 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>

【问题讨论】:

  • 问题是编译错误,如图所示

标签: android debugging uiswitch


【解决方案1】:

如果您将交换机的 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

【讨论】:

    猜你喜欢
    • 2016-02-19
    • 1970-01-01
    • 2016-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-26
    相关资源
    最近更新 更多