스위치 케이스 문으로 버튼을 입력하면 사라지고 나타나고 사라지고 나타나고를 하는 프로그램인데....
바로 맨~ 마지막에 있는 VISIBLE로 가버리네요 ㅠㅠ
어떻게 방법이 없을까요??ㅠㅠ
switch(v.getId()) {
case R.id.obutton:
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
mPage=findViewById(R.id.l13);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.l23);
mPage.setVisibility(View.VISIBLE);
mPage=findViewById(R.id.obutton);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton01);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton02);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton03);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton04);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton05);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton06);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton07);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.xButton08);
mPage.setVisibility(View.GONE);
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
mPage=findViewById(R.id.l23);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.l22);
mPage.setVisibility(View.VISIBLE);
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
mPage=findViewById(R.id.l22);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.l32);
mPage.setVisibility(View.VISIBLE);
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
mPage=findViewById(R.id.l32);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.l22);
mPage.setVisibility(View.VISIBLE);
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
mPage=findViewById(R.id.l22);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.l21);
mPage.setVisibility(View.VISIBLE);
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
mPage=findViewById(R.id.l21);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.l11);
mPage.setVisibility(View.VISIBLE);
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
MemoryGame1Activity.score=MemoryGame1Activity.score+10;
MemoryGame1Activity.stage=MemoryGame1Activity.stage+1;
a = 0;
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
abc.play(mDdok,1,1,0,0,1);
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
startActivity(new Intent(LogicGame1Activity.this, LogicGameLastActivity.class));
finish();
break;
GONE 대신 INVISIBLE 을 사용해도 마찬가지네요.....
다 건너 뛰고 맨마지막에 있는 INVISIBLE, VISIBLE 문장으로 바로가요 ㅠㅠ
정확히 말 하자면
저위에 띄우는게 다 이미지 들인데.
전부다 건너뛰고 슬립문은 읽는 것 같고...
최종이미지만 화면에 출력되네요...
어떻게 하면 해결이 될까요?>>
저거 전부 이미지들인가요??
이미지를 차례대로 보여주길 원하셨다면
mPage 하나만으로 넣은게 원인같네요.
저 코드만봐서는 잘 모르겠는데 findViewById 로 설정한게 전부 이미지뷰는 아니겠죠?
setImageResource로 해도 될텐데...
많은분들기 간과하는게 thread.sleep을 쓰면 쉬었다가 실행시킬거라 생각하는데, thread.sleep을 포함해서 모든 소스가 끝날떄까지 화면은 멈춰있습니다. 즉 마지막것만 보이고 그전까지실행되는건 먹통으로 보이지 않는단말이죠.
thread.sleep을 많이 주면 많이줄수록 그만큼 화면이 먹통이 됐다가 마지막 소스 끝날때까지 반응을 안하는거죠.
main activity에서 실행하면 당연히 안되구요.
timer나 handler postDelay를 써서 하시던지 아님 Thread를 만들어서 그 안에서 thread.sleep 후 명령을 해야 정상적으로 실행이 됩니다.
메인쓰레드에서 thread.sleep이나 systemclock.sleep을 주시면 끝날떄까지 먹통입니다ㅎㅎ



