在 xml 中使用自定义 Android 视图类时,ADT for Eclipse 中丢失属性提示是否正常?

发布于 2024-12-20 15:58:28 字数 700 浏览 3 评论 0原文

假设我创建一个扩展 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深巷少女 2024-12-27 15:58:28

发现这曾经是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文