必须声明元素 LinearLayout [英] element LinearLayout must be declared

查看:50
本文介绍了必须声明元素 LinearLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经更新了我的 android studio,现在我的 main.xml 出现问题,它显示以下错误:必须声明元素 LinearLayout

I have updated my android studio and now I have a problem in my main.xml, it displays the following error: element LinearLayout must be declared

这是我的代码:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:gravity="center_vertical|center_horizontal"
    >
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/monBouton"
        android:text="Cliquez ici !"
        >
    </Button>
</LinearLayout>

这是错误信息:

错误:任务:app:compileDebugJava"的执行失败.编译失败;详情请参阅编译器错误输出.

error : Execution failed for task ':app:compileDebugJava'. Compilation failed; see the compiler error output for details.

错误:找不到符号变量 action_settings

error : cannot find symbol variable action_settings

我该如何解决?

推荐答案

确保在菜单的 xml 文件中定义了 action_settings

Make sure you have action_settings defined inside menu's xml file

res/menu/yourmenufile.xml

像这样:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.example.app" >

    <item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        android:orderInCategory="100"
        app:showAsAction="never" />
</menu>

这篇关于必须声明元素 LinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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