Android Question

android imageview.setBackgroundResource() doesnt work

Hi i have searched the net and stackoverflow but nothing helps

i have an imageview that should be changed on click

public class Settings extends Activity implements OnClickListener
{
private ImageView im1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
im1 = (ImageView) findViewById( R.id.imageView1 );
im1.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
if (v == im1 )
{
Log.d("test", "hey!");
v.setBackgroundResource(R.drawable.img1);
}
}
}


when clicked the method runs and prints out "hey!" but the image wont change? can anyone help me


edit : forgot to mention that imageview contains another image provided by xml layout file

Answer

By convention, you should be using setImageResource(R.drawable.img1); (or setImageDrawable(getResources().getDrawable(R.drawable.img1));) instead of setBackgroundResource(R.drawable.img1);.