首页 > 移动平台 > 详细

Android常见的错误整理(不定时更新)

时间:2015-08-14 19:26:56      阅读:219      评论:0      收藏:0      [点我收藏+]
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

Android常见的错误整理(不定时更新)

原文:http://491733638.blog.51cto.com/3913830/1684729

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!