在一处更改ID会更改Android XML文件中其他位置的ID [英] Changing ID in one place changes ID in other places in Android XML file

查看:64
本文介绍了在一处更改ID会更改Android XML文件中其他位置的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将一个布局复制到另一个布局并尝试在新文件中重构ID时,便开始出现此问题.它也倾向于重构源文件中的ID.每当我尝试更新其视图的多个ID时,针对特定活动设计的布局都会发生变化,这实在令人沮丧.

This issue started happening when I copied a layout into another and tried to refactor the ID in the new file. It tends to refactor the ID in the source file also. This is quite frustrating as the layout I've designed for a particular activity gets change everytime I try to update several IDs of its views.

我是Android Studio的超级初学者,非常感谢您提供任何帮助/指导!谢谢!

I'm a super beginner in Android Studio and any kinda help/guidance would be really appreciated! Thanks!!

推荐答案

每次重构某些内容时,它将更改与该特定项目或字段相关的所有内容,如果要重构某个项目的ID,它将对其进行更改.在使用此ID的任何地方.为了更改名称,您可以右键单击并选择重构"和重命名",也可以按SHIFT + F6作为快捷方式,它会询问您是否要在注释和字符串中进行搜索,还请选中该框以进行真正的更改.使用该物品的任何地方.

every time you refactor something, it will change everything related to that particular item or field, if you want to refactor an ID of an item it will change it in everywhere this ID is being used. in order to change the name you can right click and choose refactor and rename or you can press SHIFT+F6 for a shortcut, it will ask you if you want t search it in comments and strings also check that box in order to really change it everywhere that this item is being used.

如果您只想重命名xml中的ID,而不在Java文件中对其进行更改,则必须手动以1 b/c对其进行更改,重构选项将在所有使用该ID的位置对其进行更改.您当前的项目.

If you want to rename only the ID in the xml without it being changed in the java file, you'll have to change it by hand 1 by 1 b/c the refactor option will change it everywhere it is being used in your current project.

这篇关于在一处更改ID会更改Android XML文件中其他位置的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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