tools:context =“。MainActivity”失败了,我该如何解决?

问题描述 投票:0回答:2

参数:tools:context=".MainActivity"给了我错误,另外名为:.MainActivity的部分出现红色,我该怎么办?

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android
2个回答
0
投票

您可以删除它,也可以将其更新为指向您将使用此布局资源的某个活动或片段。


0
投票

你应该找到保存你的MainActivity的文件夹。例如:enter image description here所以,检查一下。

然后,你应该了解它的功能是什么。

它用于:Lint,Android Studio布局编辑器。

此属性声明默认情况下此布局与哪个活动相关联。

这使得编辑器或布局预览中的功能需要活动知识,例如布局主题在预览中应该是什么以及当您从quickfix中进行插入时插入onClick处理程序的位置。

你可以找到更多信息here

© www.soinside.com 2019 - 2024. All rights reserved.