1.将Bitmap影像到FrameLayout,我解码的图像转换成 Drawable ,然后将其设置为背景的 FrameLayout java.lang.NoSuchMethodError: android.widget.FrameLayout.setBackground() ByteArrayInputStream imageStream2= new ByteArrayInputStream(cardbackground); Bitmap Imagebackground = BitmapFactory.decodeStream(imageStream2); Drawable imagebakground=new BitmapDrawable(getResources(),Imagebackground); framelayout.setBackground(imagebakground);
解决方法:setBackground()方法,在添加 API 级别 16。使用 setBackgroundDrawable()相反用setBackground
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { framelayout.setBackground(imagebakground); } else { frameLayout.setBackgroundDrawable(imagebakground); }
本文出自 “IT软件开发资料” 博客,请务必保留此出处http://491733638.blog.51cto.com/3913830/1684729
原文地址:http://491733638.blog.51cto.com/3913830/1684729