-1
に変更されていない私は「MainActivity.java」クラス、および内部クラスSurfaceView
を拡張しRunnable
を実装「SquashCourtView」を有します。
背景色を変更しようとしていますが、問題はありません。どんな助け?背景色が
// all required things are imported
public class MainActivity extends AppCompatActivity {
Canvas canvas;
SquashCourtView squashCourtView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
squashCourtView = new SquashCourtView(this);
setContentView(squashCourtView);
}
class SquashCourtView extends SurfaceView implements Runnable {
Thread ourThread = null;
SurfaceHolder ourHolder;
Paint paint;
public SquashCourtView(Context context) {
super(context);
ourHolder = getHolder();
paint = new Paint();
}
@Override
public void run() {
drawCourt();
}
public void drawCourt() {
if (ourHolder.getSurface().isValid()) {
canvas = ourHolder.lockCanvas();
canvas.drawColor(Color.BLACK);//the background
ourHolder.unlockCanvasAndPost(canvas);
}
}
}