0
我該如何開發一個在屏幕上以固定座標繪製線條的應用程序,設置1秒持續時間的重複定時器?在計時器的每個滴答聲上,線條都會刷新。定時器,刷新
LineRefresh.java:
package LineRefresh.xyz.com;
import java.util.Timer;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
public class LineRefresh extends Activity {
DrawView drawView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawView = new DrawView(this);
drawView.setBackgroundColor(Color.WHITE);
setContentView(drawView);
}
}
DrawView.java:
package LineRefresh.xyz.com;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
public class DrawView extends View {
Paint paint = new Paint();
public DrawView(Context context) {
super(context);
}
@Override
public void onDraw(Canvas canvas) {
paint.setColor(Color.BLACK);
canvas.drawLine(50, 200, 270, 200, paint);
}
}
'refreshs'是什麼意思?座標改變了嗎? – 2010-11-25 11:24:37
不...只有在同一座標刷新後才重新繪製線條 – hehas 2010-11-25 11:28:27