开发者

What to do when findViewById cannot find a GUI resource while debugging in Eclipse

开发者 https://www.devze.com 2023-02-23 22:38 出处:网络
Spent about an hour on this so I thought I\'d save somebody else the trouble. Using Eclipse 3.6.2. My call to findViewById a GUI widget keep returning null. Check the code and xml over and over and

Spent about an hour on this so I thought I'd save somebody else the trouble. Using Eclipse 3.6.2.

My call to findViewById a GUI widget keep returning null. Check the code and xml over and over and over, no problems. Finally exited and restarted Eclipse and开发者_如何学编程 suddenly findViewById worked.


The next time you can just delete the R.java file, and let Eclipse regenerate it, then it should work too.


I find I have been needing to do Project > Clean when adding a new resource. If I simply tell it to build, the R.java will regenerate, but the resource will not be optimized and packaged in the bundle. Chalk it up to an Android bug and remember to clean.

0

精彩评论

暂无评论...
验证码 换一张
取 消