我試圖解決這個問題,但我根本無法做到,我現在正在按照新手教程進行操作。我不斷遇到一個帶有while循環的無法訪問的代碼的錯誤,它會經常檢查持有者是否爲真。任何人都可以幫助我呢? 編輯這已經解決了,非常感謝你們的幫助,對我的愚蠢抱歉。Eclispe(Android SDK)中的「無法訪問」代碼錯誤
SurfaceHolder ourHolder;
Thread ourThread = null;
boolean isRunning = true;
public MyBringBackSurface(Context context) {
super(context);
ourHolder = getHolder();
ourThread = new Thread(this);
ourThread.start();
}
public void pause(){
isRunning = false;
while(true){
try {
ourThread.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
}
ourThread = null;
}
public void resume(){
isRunning = true;
ourThread = new Thread(this);
ourThread.start();
}
@Override
public void run() {
// TODO Auto-generated method stub
while(isRunning){
if(!ourHolder.getSurface().isValid());
continue;
Canvas canvas = ourHolder.lockCanvas(); //Unreachable code
canvas.drawRGB(02, 02, 150);
ourHolder.unlockCanvasAndPost(canvas);
}
}
}
@ SJuan76哦監管這個...刪除的評論。 –