在 xml 中使用自定义 Android 视图类时,ADT for Eclipse 中丢失属性提示是否正常?
假设我创建一个扩展 android.widget.RelativeLayout 的自定义类 MyView。然后我创建一个使用 MyView 的 xml 文件,
<com.myapp.MyView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:longClickable="true"/>
我注意到,当我编写 xml 文件时,由于继承了relativelayout,我无法从 Eclipse 获得代码提示或完成。这是正常的吗?我尝试创建一个 styleable,看看这是否有助于 Eclipse 连接各个点。我将父属性设置为 SDK 的 attrs.xml 中找到的relativelayout样式(代码如下)。这没有任何效果。 Eclipse 似乎不知道 SDK 中的样式以外的样式。这是正确的吗?
<resources>
<declare-styleable
name="MyView"
parent="@android:style/RelativeLayout"/>
</resources>
非常感谢!
Suppose I create a custom class MyView that extends android.widget.RelativeLayout. Then I create an xml file that uses MyView
<com.myapp.MyView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:longClickable="true"/>
I noticed that when I was writing the xml file, I couldn't get code hinting or completion that I would have expected from Eclipse due to inheritance from RelativeLayout. Is this normal? I experimented with creating a styleable to see if that would help Eclipse connect the dots. I set the parent attribute to the RelativeLayout styleable found in the SDK's attrs.xml (code below). This didn't have any effect. It seems Eclipse isn't aware of styleables other than the ones in the SDK. Is this correct?
<resources>
<declare-styleable
name="MyView"
parent="@android:style/RelativeLayout"/>
</resources>
Thanks much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现这曾经是 ADT 12 之前的一个问题,当时已修复。我使用的是 ADT 15,但仍然遇到问题,因为我正在使用 Eclipse 的 XML 编辑器而不是 Android 布局编辑器来编辑自定义类的布局。
发布了类似的问题。
Discovered this used to be an issue before ADT 12, when it was fixed. I was using ADT 15 but still had the problem because I was editing the layout for the custom class using Eclipse's XML editor, not the Android layout editor.
Similar question posted.