Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 可拉拔未正确加载_Android_Bitmap_Drawable - Fatal编程技术网

Android 可拉拔未正确加载

Android 可拉拔未正确加载,android,bitmap,drawable,Android,Bitmap,Drawable,我正在将drawable设置为如下按钮: button.setBackgroundDrawable(); 我将图像文件名传递给一个返回位图的方法,然后将该位图转换为可绘制的,如下所示: Drawable d = BitmapDrawable(context.getResources(), bitmap); button.setBackgroundDrawable(d); 我有两个活动A和B,现在在A中,我设置按钮可绘制,我转到B,然后返回到A,此时可绘制不可见,但当我单击按钮时,它是可见的

我正在将drawable设置为如下按钮:

button.setBackgroundDrawable();
我将图像文件名传递给一个返回位图的方法,然后将该位图转换为可绘制的,如下所示:

Drawable d = BitmapDrawable(context.getResources(), bitmap);
button.setBackgroundDrawable(d);
我有两个活动A和B,现在在A中,我设置按钮可绘制,我转到B,然后返回到A,此时可绘制不可见,但当我单击按钮时,它是可见的


我哪里出错了?

setBackgroundDrawable()
在API 16中被弃用。不久前,但值得避免的是,自API 1开始,当
setBackgroundResource(int resId)
setBackground(可绘制d)
可用时


我建议对静态内容使用
setBackgroundResource()
,并尝试上面的示例使用
setBackground(d)

您可以直接在xml文件中提供背景信息,而不是动态地提供背景信息,除非用户选择了它。不,它是动态的,所以我选择了Approaching活动A,您在代码中的何处设置背景可绘制?你能把密码寄出去吗?