1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
@Override
public boolean onTouch(View v, MotionEvent event) {
// détection appuie
if (event.getAction() == MotionEvent.ACTION_DOWN ) {
ImageButton iB = (ImageButton) v;
iB.setImageResource(R.drawable.cadena_o);
iB.setBackgroundResource(R.drawable.cadena_o);
switch (v.getId()){
case R.id.cadena_1:
mTouchButton1 = true;
break;
case R.id.cadena_2:
mTouchButton2 = true;
break;
case R.id.cadena_3:
mTouchButton3 = true;
break;
}
}
// Détection de dé-appuie lol
else if (event.getAction() == MotionEvent.ACTION_UP ){
ImageButton iB = (ImageButton) v;
iB.setImageResource(R.drawable.cadena_f);
iB.setBackgroundResource(R.drawable.cadena_f);
switch (v.getId()){
case R.id.cadena_1:
mTouchButton1 = false;
break;
case R.id.cadena_2:
mTouchButton2 = false;
break;
case R.id.cadena_3:
mTouchButton3 = false;
break;
}
}
if (this.mTouchButton1 && this.mTouchButton2 && this.mTouchButton3 )
{
// les 3 sont cliqués
}
return false;
} |
Partager