-1
을 변경하고, SurfaceView
를 확장하고 Runnable
를 구현하는 내부 클래스 "SquashCourtView"되지 않습니다.
나는 배경색을 변경하려고 시도하고 있지만 아무렇지도 않습니다. 어떤 도움이 필요합니까?배경색 내가 <strong>"MainActivity.java"</strong> 클래스가
// 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);
}
}
}