1

这是我的程序。

public class MathsExplorer extends Activity {
    /** Called when the activity is first created. */

    private GraphicsView view;
    @Override
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

       setContentView(view);

    }
}
public class GraphicsView extends View {

    public GraphicsView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    public void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);
        String background = "/Maths Explorer/bin/res/drawable/MC900436279.jpg";
        Bitmap b = BitmapFactory.decodeFile(background);
        canvas.drawBitmap(b, 10, 10, null);
    }
}

它立即退出并显示错误“不幸的是,Maths Explorer 已停止。”

谁能帮我?我不确定,我只是想显示一个图像。

4

1 回答 1

0

我认为文件的路径是错误的,你不能这样做。试试这个

于 2012-04-18T05:10:08.923 回答