【问题标题】:Android: doesn't not recognize styleable in some caseAndroid:在某些情况下无法识别样式
【发布时间】:2012-04-01 17:43:28
【问题描述】:

我在文件attr.xml 中添加了一些属性。这是它的代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <declare-styleable name="gallery_view">
        <attr name="android:galleryItemBackground"/>
    </declare-styleable>  

     <declare-styleable name="Dot">
        <attr name="color" format="color"/>
        <attr name="radius" format="dimension"/>
     </declare-styleable>

</resources>

但我不知道为什么当我使用时:

R.styleable.gallery_view_android_galleryItemBackground:没有错误。

R.styleable.Dot_color 会注意到错误,因为在 R 文件中看不到该字段。

请帮我解决这个问题。

谢谢:)

【问题讨论】:

  • android.R.styleable 类及其字段已从公共 API 中删除,请检查:stackoverflow.com/questions/6675403/…
  • 对不起,但在我的第一种情况下,我仍然可以使用它。请为我解释一下。谢谢:)

标签: android attributes styleable


【解决方案1】:
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Dot);
a.getColor....

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-11
  • 2019-12-18
  • 1970-01-01
  • 2014-04-25
  • 1970-01-01
  • 2013-07-28
  • 1970-01-01
相关资源
最近更新 更多