在新的kotlin项目中,activity_main.xml中不允许使用android:id属性 [英] Attribute android:id is not allowed here in new kotlin project in activity_main.xml

查看:170
本文介绍了在新的kotlin项目中,activity_main.xml中不允许使用android:id属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与属性相关的Kotlin的新Android Studio项目中遇到错误: 此处不允许使用android:x属性"

I get errors in new Android Studio project in Kotlin connected with attributes: 'Attribute android:x is not allowed here"

文件:activity_main.xml

file: activity_main.xml

<?xml version="1.0" encoding="utf-8" ?>
<androidx.drawerlayout.widget.DrawerLayout xmlns="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://www.w3.org/1999/XSL/Transform"
    android:id="@+id/drawer_layout" #here
    android:layout_width="match_parent" #here
    android:layout_height="match_parent" #here
    android:fitsSystemWindows="true" #here
    tools:openDrawer="start"> #here

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent" #here
        android:layout_height="match_parent" /> #here

    <com.google.android.material.navigation.NavigationView #here
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

推荐答案

尝试使用Gradle文件同步项目:File-> Sync project with Gradle files.

Try syncing project with Gradle files: File -> Sync project with Gradle files.

这篇关于在新的kotlin项目中,activity_main.xml中不允许使用android:id属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆