0
LineRefresh.java:爲什麼不刷新行?
package LineRefresh.xyz.com;
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.os.Handler;
import android.view.View;
public class DrawView extends View {
Paint paint = new Paint();
public DrawView(Context context) {
super(context);
}
@Override
public void onDraw(final Canvas canvas) {
paint.setColor(Color.BLACK);
canvas.drawLine(50, 200, 270, 200, paint);
final Handler handler = new Handler();
Runnable runnable = new Runnable() {
public void run() {
paint.setColor(Color.BLACK);
canvas.drawLine(50, 200, 270, 200, paint);
handler.postDelayed(this, 1000);
}
};
}
}
offtopic:包通常命名爲喜歡com.company.product.application.class,而不是在還原prder。 – 2010-11-25 13:35:52