Android:Eclipse 自动完成功能在 xml 文件中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9114335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:39:46  来源:igfitidea点击:

Android: Eclipse autocomplete does not work in xml files

androideclipse

提问by JJ180

I am seeing a strange problem with my Eclipse IDE for Android development.

我发现用于 Android 开发的 Eclipse IDE 有一个奇怪的问题。

Autocompletion does not work when I hit Ctrl + Space in the main.xml file for my layouts. In the bottom left, I get a message saying for example "LinearLayout not found".

当我在布局的 main.xml 文件中按 Ctrl + Space 时,自动完成不起作用。在左下角,我收到一条消息,例如“找不到 LinearLayout”。

I also have the correct namespace specified in my file.

我的文件中也指定了正确的命名空间。

It does work though for other xml files, such as my strings.xml which I find strange.

它确实适用于其他 xml 文件,例如我觉得奇怪的 strings.xml。

This is an annoyance as I'd like to easily see all the options available for a View or Layout.

这很烦人,因为我想轻松地查看可用于视图或布局的所有选项。

Anyone got any ideas on how to resolve this?

任何人对如何解决这个问题有任何想法吗?

回答by E-Riz

Check that the file is being opened in the Android XML Layout editor (not just the "plain" XML editor). Right-click the file, choose Open With, and select Android Layout Editor.

检查文件是否在 Android XML 布局编辑器(不仅仅是“普通”XML 编辑器)中打开。右键单击该文件,选择Open With,然后选择Android Layout Editor

回答by Niko K

It seems like an eclipse XML editor issue. If you declare the xmlns in other than "xmlns:android" you loose the autocompletion.

这似乎是一个 Eclipse XML 编辑器问题。如果您在“xmlns:android”以外的地方声明 xmlns,您将失去自动完成功能。

for example if you say:

例如,如果你说:

 xmlns:android="http://schemas.android.com/apk/res/android"
android:.... //AUTOCOMPLETES

if you say

如果你说

 xmlns:android1="http://schemas.android.com/apk/res/android"
android1:... //DOES NOT AUTOCOMPLETE

回答by Dmytro Danylyk

Open eclipse and go to the following:

打开eclipse并转到以下内容:

Window > preferences > XML > editor > content assist > advanced

Select all checkboxes and click ok. After that, restart eclipse.

选择所有复选框并单击确定。之后,重新启动eclipse。

回答by resw67

Try this as suggested powder366

按照建议的方法试试这个Powder366

Or you can set the default editor in Eclipse Preferences, used Android Common XML Editor. You find it in Eclipse Preferences, General, Editors, File Associations. Click on .xml, choose "Add" "Android Common XML Editor". Select it and press the Default button.

或者您可以在 Eclipse Preferences 中设置默认编辑器,使用 Android Common XML Editor。您可以在 Eclipse Preferences、General、Editors、File Associations 中找到它。单击 .xml,选择“添加”“Android 通用 XML 编辑器”。选择它并按默认按钮。