我在循环中调用draw类来绘制一堆行,但我只有一行 这是抽奖类:
class DrawView extends View {
Paint paint = new Paint();
public DrawView(Context context) {
super(context);
paint.setColor(colorr[thecolore[0]]);
paint.setStrokeWidth(10);
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawLine(clickat[0], clickat[1], clickat[2], clickat[3], paint);
clickat[0] = -1;
clickat[1] = -1;
clickat[2] = -1;
clickat[3] = -1;
}
}
(我将一些动态浮动传递给表clickat) 我有这个循环:
for(int i=0; i<regenlinks[myposition].length;i+=8){
if(regenlinks[myposition][i] !=-1 ){
clickat[0] = X+30;
clickat[1] = Y+30;
clickat[2] = (float)regenlinks[myposition][i+3];
clickat[3] = (float)regenlinks[myposition][i+4];
thecolore[0] = (int)regenlinks[myposition][i+5];
RelativeLayout mapView = (RelativeLayout) findViewById(R.id.rlayou);
DrawView drawView = new DrawView(maps.this);
drawView.setId((int)regenlinks[myposition][i+6]);
mapView.addView(drawView);
}
}
但是当循环结束时绘制的唯一一行是最后一行。有什么想法吗?