안드로이드 개발 질문/답변
(글 수 358)
Button.OnClickListener mClickListener = new Button.OnClickListener() { public void onClick(View v) { 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;
break;
시간에 따라
일 정간격을 두고 겹쳐져있는 이미지를 같은위치에 차례로 띄우려고하는데요...
중간 과정 다 건너띄고 바로 제일 밑에있는 GONE, VISIBLE 있는 곳으로 가네요...
mPage=findViewById(R.id.l21);
mPage.setVisibility(View.GONE);
mPage=findViewById(R.id.l11);
mPage.setVisibility(View.VISIBLE);
이부분으로 바로가네요....
이거 하려면 어떻게 해야 될까요???
INVISIBLE 이요??
소용 없습니다..
Handler handler = new Handler(){
public void handleMessage(Message msg){
super.handleMessage(msg);
}
};
handler.sendEmptyMessageDelayed(0,1000);
이 안에 넣어도 소용없구요...
이거 어떻게 하면 될까요???
전체 소스 첨부합니다.
2012.06.21 13:41:03
방금 이 질문보고 ImageView에 간단하게 이미지를 변경 해 봤습니다.
private int[] resources = {R.drawable.img_01, R.drawable.img_02, R.drawable.img_03, R.drawable.img_04}; private int count = 0; Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); iv.setImageResource(resources[count]); count++; if (count < resources.length) { sendEmptyMessageDelayed(0, 200); } } };
onClick()에서
handler.sendEmptyMessage(0);
한번 실행해주면 됩니다..
버튼이나 다른 뷰들도 이와 같은 방식이니 참고해보세요..
왜 왜 mPage를 전역으로 사용하는지 이해가 안가네요..
소스를 자세히 보지 않아서 잘 모르겠지만..
세팅용으로만 사용하시는거 같은뎅..