1

I'm having trouble getting Eclipse to see that I've just put a new image into my project when referencing that image using R.drawable.this_text

So I drag my png into myProject/res/drawable-hdpi in Eclipse's Project Explorer. The name of the image is this_text and it's a png!

So I go into my application and I want to put this on the screen; So here's the code for that...

private void setTitle()
{
ImageView title = new ImageView(this); //this extends activity
title.setBackgroundResource(R.drawable.this_text);
...
}

This I have done before and each time I do it I experience the same thing: if i just dragged my this_text.png into the Project Explorer in eclipse, the word "this_text" will be underlined in red, and not allow me to compile or proceed. I try to F5 (refresh) the project. I try refreshing the image foldr, the src, the actual java...etc! I try closing and opening eclipse but nothing really works. So I quit for afew minutes and work elsewhere in my application, and eventually this error goes away!

Well I'm impatient today-- And I'd rather know how to solve this incase I need to do any quick programming! So does anyone know what to do?

I'm using eclipse Version: Indigo Service Release 1.

Thanks- Ethan

4

1 回答 1

1

生成 android 的 R 文件。而不是刷新,您应该能够 CLEAN 应该解决您的问题的项目。您甚至可以从问题列表中删除错误,以便开始编译并创建生成的 R 文件。或者您可以对 xml 进行更改,这也将允许重新生成文件。一如既往地确保您的工具链是最新的。

于 2012-03-09T19:17:12.373 回答