【发布时间】:2011-04-12 04:09:47
【问题描述】:
所以我创建了一个名为“drawable view”的视图
class DrawableView extends View{
Context mContext;
int touches=0,k,Xoffs,clicks=0;
double x_1 = 0,x_2=0;
private float mLastTouchX, mLastTouchY;
public DrawableView(Context context) {
super(context);
mContext = context;
}
....
@Override
protected void onDraw(Canvas canvas){
Paint myPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
canvas.drawColor(Color.BLUE);
myPaint.setColor(Color.WHITE);
canvas.drawCircle(200, 100, 20, myPaint);
}
..... more code....
}
而且只能在 ondraw 命令中失效!即:调用“invalidate();”在 ondraw 命令结束时会导致它循环。
我已经多次尝试调用 g_draw.invalidate();或 g_draw.postInvalidate(); (g_draw 是创建的可绘制视图的名称)来自其他类甚至主活动类,它不起作用。为什么以及如何解决?
谢谢
【问题讨论】:
标签: android invalidation