Android gets the background resources for ImageButton… here is a solution to the problem.
Android gets the background resources for ImageButton
I
need to get some of ImageButton’s background resource to reuse it later, and I set the background using setBackgroundResource. I can’t find any way to get background resources.
private void AddImage(int img){
ImageButton imgact1 = (ImageButton)findViewById(R.id.imgact1);
ImageButton imgact2 = (ImageButton)findViewById(R.id.imgact2);
ImageButton imgact3 = (ImageButton)findViewById(R.id.imgact3);
imgact3.setBackgroundResource(img);
}
Thanks for your help.
Solution
For any View
, you should use getBackground(),
which returns a Drawable
.