Android XML 编辑器和 Eclipse 的问题...很难手动编辑 XML
自从我上次开发 Android 应用程序以来已经有几年了。从那时起,Eclipse 中添加了一个图形编辑器,允许您以所见即所得的方式生成布局的 XML(Android sdk 的一部分)。我喜欢它。加快速度。
然而,使用这个编辑器,我在“xml 视图”而不是“图形布局”视图中编辑 xml 很费时间。
当在XML视图中时,我无法再使用很多快捷键。就像 ctl-c 或 ctl-v (剪切和粘贴)一样,最令人沮丧的是我无法使用“删除”键。当我执行剪切和粘贴时,什么也没有发生。检查剪贴板,我可以看到一开始就没有复制任何内容。当按下删除键时,会发生奇怪的副作用。有时什么都没有...有时输入小部件被删除。我想不通。
在 XML 视图中,我可以使用鼠标进行剪切和粘贴,一切都很好。我可以使用“退格”键而不是删除键来删除文本。所以我可以毫无问题地将所有东西放在那里。但是……这是<strong>背部的主要疼痛。 20 年来我一直在以某种方式进行编程,但很难让自己使用鼠标进行剪切、粘贴等操作。
还有其他人经历过这个吗?我在互联网上没有找到与此问题相关的任何内容。
注意:我知道我可以更改 Eclipse 中的编辑器首选项以仅使用普通的 eclipse xml 编辑器,但我失去了所见即所得的显示...这对于可视化来说非常好。
如果您看到这个问题或知道解决它的方法...请,请,请告诉我。
我不认为这有什么区别,但这是我的规格。
蚀: 版本:4.1.0 内部版本号:M20110912-1510
Android 开发工具 12.0.0.v201106281929-138431
It's been a few years since I have last developed android apps. Since then, a graphical editor was added to Eclipse that allows you to generate the XML for an layout in a WYSIWYG fashion (part of the android sdk). I like it. Speeds things up.
However, with this editor I am having a heck of a time editing the xml in the "xml view" as opposed to the "graphical layout" view.
When in the XML view, I can no longer use a lot of shortcut keys. Like ctl-c or ctl-v (cut and paste) and most frustratingly I can't use the "delete" key. When I perform a cut and paste, nothing happens. And checking the clipboard, I can see that nothing gets copied in the first place. When hitting the delete key, strange side effects happen. Somtimes nothing...othertimes enter widgets are removed. I can't figure it out.
While in the XML view, I can use the mouse to cut and paste and everything is fine. I can use the "backspace" key to remove text instead of the delete key. So I can get everything in there with no issues. But...this is a major pain in the backside. I have been programming certain ways for 20 years and it is hard to get myself to use the mouse to cut and paste and whatnot.
Has anyone else eperienced this?? I haven't found anything on the internet pertaining to this problem.
Note: I know I can change the editor preferences in Eclipse to just use the normal eclipse xml editor but I lose the WYSIWYG display...which is nice to have for visualization.
If you have seen this problem or know of a way to get around it...please, please, please let me know.
I don't think it makes a difference, but here are my specs.
Eclipse:
Version: 4.1.0
Build id: M20110912-1510
Android Development Tools 12.0.0.v201106281929-138431
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
该问题已在今天发布的 ADT 20 Preview 3 中修复。
http://tools.android.com/download/adt-20-preview
This is fixed in ADT 20 Preview 3, released today.
http://tools.android.com/download/adt-20-preview
虽然这不完全是一个解决方案(希望不会给我带来一些反对票),但我发现一个很好的折衷方案是打开布局两次,一次在 android 布局编辑器中,一次在普通 XML 编辑器中。
您可以通过右键单击该文件(或者我假设在 mac 上按住 alt 键)并选择“打开方式”来完成此操作,您应该看到所有不同的 android 编辑器、文本编辑器和 XML 编辑器。
打开它两次的好处是你可以并排放置它(将它拖到另一个窗格),现在唯一的问题是你必须将焦点放在 android 布局编辑器上才能更新,但是在至少你有快捷键和删除键。
Although this is not exactly a solution (and hopefully doesn't earn me some downvotes) I've found a nice compromise is to open the layout twice, once in the android layout editor and once in the normal XML editor.
You can do this by right clicking the file (or alt clicking on mac I assume) and selecting "Open With", you should see all the different android editors, a text editor and an XML editor.
The nice thing about opening it twice is you can have it side-by-side (drag it to another pane), the only issue now is that you have to give focus to the android layout editor in order for it to update, but at least you have your shortcuts and delete keys.
我找到了解决方法(修复)。在首选项->按键中重新定义复制粘贴的快捷键为其他一些组合键,然后标准的 cmd-c cmd-v 就会开始工作。我没有遇到删除问题,但它可能适用于其他关键问题。我用的是 mac,所以没有在 windows 上测试。
I found workaround(fix). Redefine shortcuts for copy and paste in preferences->Keys to some other key combinations, then standard cmd-c cmd-v will start work. I did not had issues with delete, but it may work for other key issues. I am on mac so not tested on windows.
我也可以确认这种行为,虽然我不记得在早期版本的 Eclipse 上有过这个问题,所以我强烈怀疑是 4.x 版本的 Eclipse 干扰了 xml 编辑器,我甚至使用更新的 4.2+
编辑:你可以想要跟踪此问题 http://code.google.com/p/android/issues/detail?id=27155
I can also confirm this behavior, though I didn't recall having this problem on earlier version of Eclipse so I strongly suspect it's the 4.x version of eclipse that's interfering with the xml editor, I use even newer 4.2+
edit: you may want to track this issue http://code.google.com/p/android/issues/detail?id=27155
我有同样的问题,删除,ctrl-v 在截至 2012 年 7 月的最新 Eclipse 中无法使用 Linux Mint 64 位上的最新 Android 插件。
肯定是(至少在我的例子中)android XML 编辑器出了问题。正如 Damon 所说,使用 eclipse 用“open with”打开 xml,而不选择 android 编辑器可以解决这个问题。 android编辑器可以并行打开。
I have the same issues, delete, ctrl-v not working in the latest Eclipse as of July 2012 with the latest Android plugin on Linux Mint 64 bit.
It's definiteley (in my case at least) the android XML editor that is at fault. As Damon says, opening the xml using eclipse with "open with" and not choosing the android editor fixes the issue. The android editor can be open in parallel.
您可以通过手动定义命令和快捷键
Windows > 首选项 > 一般 > 按键
我实际上复制“Ctrl + C”、“Ctrl + V”、“Ctrl + Y”、“Ctrl + Z”命令并定义“当”为“编辑 XML 源”。
有用!
You can manually define commands and shortcut keys through
Windows > Preferences > General > Keys
I actually copied "Ctrl + C", "Ctrl + V", "Ctrl + Y", "Ctrl + Z" commands and define the "When"s as "Editing XML source".
It works!
我面临的问题,在这里进行了演示(不是我发布的)
http://www.youtube.com/watch?v=nUnOesjL1IE,
通过禁用“自动格式化由可视布局编辑器编辑的 XML”来修复。
布局 XML 的格式肯定消失了,但至少我可以正确编辑该文件。
The issue I face, which is demo-ed here (not posted by me)
http://www.youtube.com/watch?v=nUnOesjL1IE,
is fixed by disabling "Automatically format the XML edited by the visual layout editor".
The formatting for layout XML is gone for sure, but at least I can edit the file properly.
在Word中,“工具”-“选项”-“编辑”选项卡,确保选中“键入替换选择”。然后空格键将用于删除文本。
In word, Tools - options - Edit tab, be sure the typing replaces selection is checked. Spacebar key will then work to delete text.