 悬赏园豆:5
                [已关闭问题] 
            
                    关闭于 2012-05-15 23:24
                悬赏园豆:5
                [已关闭问题] 
            
                    关闭于 2012-05-15 23:24
                 
         public class PictureView extends View
public class PictureView extends View
{
    public PictureView(Context context)
    {
        super(context);
    }
    Resources r = this.getContext().getResources();
    InputStream is = r.openRawResource(R.drawable.tree);
    BitmapDrawable  bmpDraw = new BitmapDrawable(is);
    Bitmap tree = bmpDraw.getBitmap();   
    int length=tree.getWidth();
    int height=tree.getHeight();
    Paint paint;
    public void onDraw(Canvas canvas)
    {
            Bitmap[] bitmap=new Bitmap[9];
            Bitmap[] bitmapTransfer=new Bitmap[3];
            for(int i=0;i<3;i++)
            {
                bitmapTransfer[i]=Bitmap.createBitmap(tree, 0, i*height/3,length,height/3);
                for(int j=0;j<3;j++)
                {
                    bitmap[i*3+j]=Bitmap.createBitmap(bitmapTransfer[i], j*length/3,0,length/3,height);
                }
            }
            
        canvas.drawBitmap(bitmap[0], 70, 100, paint);
    }
}
这是自定义的View,activity的代码就是显示这个view
这一段代码,在运行安卓的时候,程序直接报错,请问哪里有错?我看logcat,好像说是数组的长度超过了范围,但是我没感觉这个数组有问题啊
for(int j=0;i<3;i++) { bitmap[i*3+j]=Bitmap.createBitmap(bitmapTransfer[i], j*length/3,0,length/3,height); }
for里的j<3;j++写是i<3;i++了
谢谢,不过改过来之后还是有问题的
05-15 15:23:23.001: E/AndroidRuntime(360): java.lang.IllegalArgumentException: y + height must be <= bitmap.height()
实在是不知道哪个逻辑有问题了