如何在 Eclipse 中重命名小部件 ID?
我正在开发一个基于教程中的示例构建的应用程序。现在,不同的小部件 ID 不再反映其用途,因此我想重命名它们。然而,这似乎是一项艰巨的任务,因为 ID 在多个文件中使用。
是否可以以某种方式重命名 ID,以便将更改迁移到项目中的其他文件中?这与重构源代码名称非常相似,但对于小部件 ID 而言。
I am working on an app built upon an example from a tutorial. Now the different widget IDs no longer reflect their purpose so I would like to rename them. However, this seems quite a task as the IDs are used in multiple files.
Is it possible somehow to rename the IDs so the changes are migrated into the other files in the project? That is pretty much similar to refactor source code names, but for widget IDs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为 Eclipse 中不存在这样的工具。手动执行此操作的最简单方法是重命名 XML 布局中的项目,然后跟踪 Java 类中的错误。如果你一个接一个地做,那么你应该在一两分钟内就把它清理干净。
I don't think a tool like that exists in Eclipse. The easiest way to do it manually is to rename an item in the XML layout and then track down the errors in the Java classes. If you do it one-by-one then you should have it cleaned up in a minute or two.
您可以尝试使用Eclipse的查找/替换功能。我发现这在更改 ID 或其他类似内容时很有用。让我们知道您最终会做什么。
You can try to use the Find/Replace function is Eclipse. I have found this useful several times when changing ID's or something to that effect. Let us know what you end up doing.
在 Eclipse 中:
转到 xml 布局
->图形布局-> Properties
,然后单击所需字段附近的...
按钮:In eclipse:
Go to the xml layout
-> Graphical Layout -> Properties
then click the...
button near the desired field:如果现在有人偶然发现这个问题,您可以从可视布局编辑器中重命名 ID,它会自动完成所有艰苦的工作。
In case anyone stumbles across this problem now, you can rename the ID from the visual layout editor and it will do all the hard work automatically.