3

我需要获取一些 ImageButton 的背景资源,以便稍后重新使用它,以设置我使用 setBackgroundResource 的背景。我没有找到任何方法来获取背景资源。

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);
}

谢谢你的帮助 。

4

1 回答 1

4

至于任何View,你应该使用getBackground(),它返回一个Drawable

于 2013-04-21T12:03:50.570 回答