在安卓中,如何从imagebutton中提取图像?
我有两个imagebutton,我想切换彼此的图像,这样按钮a将有按钮b的图像,而按钮b将有按钮a的图像。我试图在我的代码中实现这一点,但它不起作用
Bitmap temmp = a1.getDrawingCache();
a1.setImageBitmap(a2.getDrawingCache());
a2.setImageBitmap(temmp);
你可以在下面搜索框中键入要查询的问题!
我有两个imagebutton,我想切换彼此的图像,这样按钮a将有按钮b的图像,而按钮b将有按钮a的图像。我试图在我的代码中实现这一点,但它不起作用
Bitmap temmp = a1.getDrawingCache();
a1.setImageBitmap(a2.getDrawingCache());
a2.setImageBitmap(temmp);
# 1 楼答案
在用
setDrawingCacheEnabled(true)
调用getDrawingCache()
之前,需要enable the drawing cache