class NumBtnListener implements OnClickListener
{
int btnId;
int index;
public final static int PLAY = 1; // 여기요!!!!
public final static int STOP = 2; // 여기요!!!!
public NumBtnListener(int btn_id, int index)
{
btnId = btn_id;
this.index = index;
}
/////////////////////////////////////////////////////////////////////////////////
// 여기요!!!!
/////////////////////////////////////////////////////////////////////////////////
public Handler h = new Handler(){
public void HandleMessage(Message msg){
switch(msg.what)
{
case PLAY:
sound.play(sound1, 1, 1, 0, 0, 1);
break;
case STOP:
sound.stop(sound1);
sound1 = sound.load(getApplicationContext(), R.raw.btsound,0);
break;
}
}
};
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Animation ani = AnimationUtils.loadAnimation(GameMain.this, R.anim.scale);
ImageButton imgbtn = (ImageButton) findViewById(btnId);
imgbtn.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
h.sendEmptyMessage(PLAY);
break;
case MotionEvent.ACTION_UP:
h.sendEmptyMessage(STOP);
break;
}
return true;
}
});
ani.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
. . .
bld.setPositiveButton("예", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
m.init();
for(int i = 0; i < 25; i++)
{
numBtns.get(i).setImageResource(R.drawable.n);
numBtns.get(i).refreshDrawableState();
}
// btnReady.setEnable(true);
}
});
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
finish();
}
});
bld.show();
}
}
}
});
imgbtn.startAnimation(ani);
}
}
위에 까만 부분을 이용해서
애니메이션 리스너로 인해 변하는 이미지 버튼을 터치리스너를 이용해서
효과음이 나오게 하려고 하는데요....
뭐가 안되는건지... 버튼을 클릭하면 소리는 안나고 애니메이션만 변하네요....