android - Eclipse Android 插件未列出自定义组件自动完成的属性

标签 android eclipse-plugin

一般来说,Eclipse Android 插件可以按预期自动完成工作。但是,它不适用于我编写的自定义控件。基本上,除了默认的命名空间选项之外,自动完成列表是空的。

该控件继承自 Button 小部件并添加了一些额外的文本。我有几个额外的属性,我使用它们定义的:

<?xml version="1.0" encoding="utf-8"?>
<resources> 
    <declare-styleable name="SubTextButton"
        <attr name="sub_text" format="string" />
        <attr name="sub_text_size" format="float" />
        <attr name="sub_text_color" format="color" />
    </declare-styleable>
</resources>

否则它会使用 Button 小部件的所有标准属性。

在布局文件中我指定了命名空间:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.mycompany"
    ...

我使用控件:

<com.mycompany.SubTextButton
    android:layout_width="@dimen/status_bar_button_w"
    android:layout_height="@dimen/status_bar_button_h"
    android:layout_alignParentRight="true"
    android:background="@drawable/button_bg"
    android:text="HCD"
    android:textColor="@color/static_text"
    android:textSize="@dimen/font_size_standard"
    app:sub_text="SET"
    app:sub_text_size="12.0"
/>

一切正常,但用户无法利用自动完成功能来查看哪些属性可用。理想情况下,我希望看到继承的 Button 属性以及我定义的自定义属性。

有什么想法吗?

最佳答案

在 Eclipse helios 和 ADT v0.9.7 上它对我也不起作用

但是,这是可能的(感谢 resources xml 文件和父类的自省(introspection))。 我查看了(比预期更长的时间)ADT 源代码(我喜欢开源),我认为它应该可以工作。来自 AndroidContentAssist 的方法 computeAttributeProposals(...)读取 ElementDescriptor 中的属性,由于 CustomViewDescriptorService,它们似乎应该为自定义控件正确初始化

关于android - Eclipse Android 插件未列出自定义组件自动完成的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4389464/

相关文章:

android - 动态 Textview 滚动条不显示

java - Android keystore 签名问题

java - R.java 文件从未生成

eclipse - 当任务运行完成时,eclipse 可以通知我吗?

Android:系统调用期间出现 SSLException I/O 错误,连接超时

android - 以编程方式在线性布局中添加多个框架布局

eclipse - 在 Eclipse 中从实体类文件生成接口(interface)

java - 带有 java.lang.ClassNotFoundException 的 SWT FileDialog

eclipse - 查找 JavaModelUtil.getResolvedTypeName 的替代品

java - 在二进制类型上使用 IMethod.exists() 方法