views:

80

answers:

2

In the following code, these lines: "score.setText(shops[i].getScore());" and "icon.setImageResource(R.drawable.test1);"

the app keep throws the Rescources.NotFoundException. I checked the xml file, all the ids are defined and they are all in the R.java. So I really don't know why the app throw this exception. Could anyone help me on this problem? Thank you very much!!!

 try{
 TextView name= (TextView)findViewById(R.id.name);
 TextView description = (TextView)findViewById(R.id.description);
 TextView score = (TextView)findViewById(R.id.score);
 ImageView icon = (ImageView)findViewById(R.id.icon);

 name.setText(shops[i].getName());
 description.setText(shops[i].getDescription());
 score.setText(shops[i].getScore());

 UrlImage urlImage = new UrlImage(context,shops[i].getIconUrl());
    Drawable drawable = urlImage.getDrawable(context);
    if(drawable!=null){
     icon.setImageDrawable(urlImage.getDrawable(context));
    }else{
     icon.setImageResource(R.drawable.test1);
    }
 }catch(NotFoundException e){
   Toast.makeText(walkstreet.this,
     "marker"+i,
     Toast.LENGTH_SHORT).show();
 }
A: 

Inside of Eclipse, try doing a Project > Force Clean. Outside of Eclipse, delete your bin/ and gen/ directories. In either case, after doing the above, try rebuilding.

Sometimes, when you add resources, Android changes the resource ID numbers but does not recompile everywhere those numbers are used.

CommonsWare
thank you for your andswer. But it doesn't work it seems.When I check the ddms, I find that the id for the resource in the info is not normal and it is different with the id in R.java. I think that's what cause the problem but I still doesn't know how to fix it.
Mak Sing
A: 

It ends up it is data type problem.... Integer cannot be put in the setText(). lol Interesting how the exception is not related at all. and the compiler do not throw any error when it is being compliled.

Mak Sing