Eclipse Android项目 为控件添加了Id,但是在Java代码中提示xxx cannot be resolved or is not a field
来源:互联网 发布:淘宝代付被骗怎么办 编辑:程序博客网 时间:2024/06/06 07:05
在Android开发过程中,常需要在布局文件中为控件添加Id,以便在Java代码中找到这个控件。
但在使用Eclipse进行开发的过程中,常会出现明明已经在Layout XML文件中为组件添加了Id,并且保存。但在代码中使用findView方法时,仍然寻找不到相应的id,系统报错提示 xxx cannot be resolved or is not a field。
原因可能是Eclipse本身编译的问题,也可能是导入R文件的不正确。
针对相应的原因,可尝试以下的几种方法
- 对项目进行clean操作 工具栏 project->clean
- 对项目选择自动构建 工具栏 project->Build automatically
- 删除项目gen文件夹,重新Build
- 确认是否导入了项目本身的R文件,一般都是import packageName.R,其中packageName为项目本身的包名
转载链接:http://blog.csdn.net/u012145166/article/details/49700717
阅读全文
0 0
- Eclipse Android项目 为控件添加了Id,但是在Java代码中提示xxx cannot be resolved or is not a field
- Eclipse Android项目 为控件添加了Id,但是在Java代码中提示xxx cannot be resolved or is not a field
- R.xxx cannot be resolved or is not a field
- XXX cannot be resolved or is not a field
- xxx cannot be resolved or is not a field
- xxx cannot be resolved or is not a field
- android项目中出现out cannot be resolved or is not a field错误
- 添加jar包编译出现错误"XXX cannot be resolved or is not a field"解决方法
- 在android编程中出现cannot be resolved or is not a field
- eclipse中system.out.println()出现问题,总是提示out cannot be resolved or is not a field
- Android Question - “Id cannot be resolved or is not a field” error?
- Android R.id.xxxx cannot be resolved or is not a field
- Android工程中加入图片,报错cannot be resolved or is not a field
- Android中cannot be resolved or is not a field错误的解决办法
- Android工程中加入图片,报错cannot be resolved or is not a field
- Android中cannot be resolved or is not a field错误的解决办法
- R.layout.xxx cannot be resolved or is not a field问题解决办法
- layout读取不到显示“id cannot be resolved or is not a field”
- Magento事件event的dispatchEvent分发使用方法:
- 详解Java三种内存溢出java.lang.OutOfMemoryError: unable to create new native thread,Java heap space,PermGen
- 如何画 软件工程 流程图
- 我的 Android 面试故事(2017下半年)
- XRecyclerview刷新加载
- Eclipse Android项目 为控件添加了Id,但是在Java代码中提示xxx cannot be resolved or is not a field
- 关于 VMware Ubuntu的安装
- 剑指offer面试题七之重建二叉树
- 枚举
- OI生涯最后一次算法博客?(雾
- 解决FileOutputStream中文乱码问题
- 求最大值
- 初识Spring_01
- webservice通信调用天气预报接口实例