Eclipse Android plugin not listing attributes with auto-complete for custom component
In general, the Eclipse Android plug in is working as expected with auto-complete. However, it is not working for a custom control that I wrote. Basically, the auto complete list is empty other than the default namespace options.
The control inherits from the Button widget and adds some additional text. I have a couple of extra attributes that I use defined as such:
<?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>
otherwise it uses all the standard attributes of the Button widget.
In the layout file I specify the namespace:
<?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"
...
and I use the control:
<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"
/>
Everything works fine, but users don't have the benefit of the auto-complete to see what att开发者_运维知识库ributes are available. Ideally, I'd like to see the inherited Button
attributes as well as the custom attributes I've defined.
Any ideas?
It does not work for me, either, on Eclipse helios with ADT v0.9.7
However, it could be possible (thanks to the resources
xml file and the introspection of the parent class).
I had a (longer than expected) look in the ADT source code (I love open-source), and I think it should work. The method computeAttributeProposals(...)
from AndroidContentAssist
reads attributes in an ElementDescriptor
and it seems they should be correctly initialized for custom controls thanks to CustomViewDescriptorService
I found that closing all the Properties views and reopening caused my custom attributes to be shown
精彩评论