styleable cannot be resolved or is not a field

ComoneC 2014-11-07 03:43:12
在res/values/attrs.xml中写下如下代码:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="TileView">
<attr name="tileSize" format="dimension"></attr>
</declare-styleable>
</resources>

然后在TileView.java文件中如下:
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TileView);
mTileSize = a.getDimensionPixelSize(R.styleable.TileView_tileSize, 12);

a.recycle();

结果styleable处出现红色下划波浪线,提示错误为:styleable cannot be resolved or is not a field
...全文
520 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
优雅de程序员 2016-02-24
  • 打赏
  • 举报
回复
引用 2 楼 ComoneC 的回复:
好像是,也好像不是,反正我删了一些没有用到的Import包,它就好了!
卧槽,我找了很久,把 import android.R; 这个已删除就好了 谢谢大神啦
ComoneC 2014-12-05
  • 打赏
  • 举报
回复
好像是,也好像不是,反正我删了一些没有用到的Import包,它就好了!
冥王之锤 2014-11-07
  • 打赏
  • 举报
回复
没有import R所在的包。

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧