升级到Android Studio 3.3后,“错误:':'不是有效的资源名称字符”

时间:2019-02-10 16:36:08

标签: android xml android-studio android-layout

我一直在开发一个定期更新的旧Android项目。 现在,升级到Android Studio 3.3后,出现此错误:

Error: ':' is not a valid resource name character

在以下res / layout文件中:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:background="#4d4d4d">

    <ListView
        android:id="@+id/android:list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/deleteAll">
    </ListView>

    <TextView
        android:id="@+id/favourite"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/fav"
        android:textColor="@color/white" />

    <Button
        android:id="@+id/deleteAll"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/yellow_button_event"
        android:text="@string/delete_fav" />        
</RelativeLayout>

我在StackOverflow上找到了很多有关此问题的答案,但没有一个让我知道我的问题是什么。

您知道这可能是什么问题吗?

1 个答案:

答案 0 :(得分:4)

android:id="@+id/android:list"

这应该是您的错误。现在,除非您实现了我不熟悉的某些功能,否则我知道这是不好的命名约定。我认为这个特定的角色直到3.3才被强制使用

我会用..

android:id="@+id/list_favourite

这是一个great website,具有各种Android命名约定。

相关问题