Reputation: 1
Hi I am beginner in android and I am trying to learn it, I wrote a small code for changing the background
image of the application when clicking on some button:
public void processClicks(View display)
{
display.setBackgroundResource(@drawable/fgd4);
}
but it got me an error message that : drawable cannot be resolved to a variable fgd4 cannot be resolved to a variable
but I have created a folder named drawable
in the res
folder and I put the fgd4.jpg
image in it.
Please help me to solve this small problem
Upvotes: 0
Views: 48
Reputation: 1600
You must reference your drawable in code differently than you do in your XML layouts.
display.setBackgroundResource( R.drawable.fgd4 );
Upvotes: 1
Reputation: 1347
Try Like This:
display.setBackgroundResource(R.drawable.fgd4);
Upvotes: 0