首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >drawBitmap context.getResource空

drawBitmap context.getResource空
EN

Stack Overflow用户
提问于 2014-08-04 16:02:11
回答 1查看 80关注 0票数 0

嗨,我正在尝试使用位图来设置一个图像,但是我的上下文中有一个空点异常

这是我的密码。

代码语言:javascript
复制
public class Helper extends Activity {
//my code
private static Helper  _instance;

    public Helper() {
        _instance = this;
    }                                 

    public static Context getContext() {
        return _instance;
    }
//code
private static void draw(Canvas canvas, String letters, int tileColor,
            int textColor, int left, int top, int right, int bottom) {
//code
            canvas.drawBitmap(BitmapFactory.decodeResource(_instance.getResources(),
            R.drawable.wine), (right + left) / 2 - width / 2, (top + bottom)
            / 2 + rect.height() / 2, null);

}

我做错什么了?我的错误在_instance.getResources()

EN

回答 1

Stack Overflow用户

发布于 2014-08-05 20:38:05

我在我的方法中添加了上下文,解决了我的错误。

代码语言:javascript
复制
    private static void draw(Canvas canvas, String letters, int tileColor,
                int textColor, int left, int top, int right, int bottom, Context context) {
                   //my code

}

谢谢你们

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25122866

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档