onDraw(Canvas canvas) 自动工作。在这个视图中,onTouch() 方法监听触摸屏幕。单击屏幕时,我需要重新绘制矩形,但它没有绘制矩形画布。
public class Viewer extends View implements OnTouchListener{
public Viewer(Context context) {
super(context);
.............
..............
this.setOnTouchListener(this);
}
@Override
public void onDraw(Canvas canvas){
super .onDraw(canvas);
drawBackGround(imgObj.bg01, canvas);
}
@Override
public boolean onTouch(View v,MotionEvent event) {
// TODO Auto-generated method stub
Canvas c = new canvas();
c.drawRect(.......); //<------ It's work but it isn't redraw
return true;
}