简体   繁体   English

如何从 Android Studio 中完全删除 Android 布局

[英]How to Completely Remove an Android Layout from Android Studio

I'm building an app in Android Studio and I accidentally created a base LoginActivity template but then deleted it because I wanted to make my own.我正在 Android Studio 中构建一个应用程序,我不小心创建了一个基本的LoginActivity模板,但后来删除了它,因为我想自己制作。 Now, when I try creating another activity with the same name, it tells me "Layout name must be unique."现在,当我尝试创建另一个具有相同名称的活动时,它告诉我“布局名称必须是唯一的”。

I could just name it something else but:我可以将其命名为其他名称,但是:

  1. I don't want to我不想
  2. There would still be some sort of duplicate files in my system doing nothing我的系统中仍然会有某种重复文件什么都不做

My goal is to just remove all mentions of activity_login , ultimately so I can make a new activity with the same name, but I can't figure out how.我的目标是删除所有提及的activity_login ,最终我可以创建一个同名的新活动,但我不知道怎么做。

Go to res->layout->activity_login.xml and delete it from android studio转到res->layout->activity_login.xml并将其从 android studio 中删除

Or open project in file explorer, then Go to app/src/main/res/layout/activity_login.xml and delete it或者在文件资源管理器中打开项目,然后转到app/src/main/res/layout/activity_login.xml并删除它

If it didn't solve it, Invalidate Caches and restart Android Studio.如果它没有解决它,使缓存无效并重新启动Android Studio。

That's happens sometimes.有时会发生这种情况。 just go to : File->Manage IDE Settings -> Restore Default Settings .只需转到: File->Manage IDE Settings -> Restore Default Settings This will solve it for sure :)这肯定会解决它:)

I had the same problem.我有同样的问题。 Empty res/layout/activity_xxxxx.xml and invalidate cache didn't work, until I found there's xxxxx.java existing in app\\src\\main\\java\\com\\example\\xxxxx .res/layout/activity_xxxxx.xml和无效缓存不起作用,直到我发现app\\src\\main\\java\\com\\example\\xxxxx中存在xxxxx.java After deleting the .java file as well, I found that I'm able to create the Activity file with the same name.删除 .java 文件后,我发现我可以创建同名的 Activity 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM