mercredi 18 juin 2014

Use onTouchEvent and onclick event together


Vote count:

0




I'm having trouble with enabling buttons while the onTouchEvent is active. In my app the user is supposed to press anywhere on the screen to see a text and while pressing the screen press a button. The problem is that while the onTouchEvent is active the buttons doesnt work. is there anyway to enable buttons while the onTouchEvent is active?


My code for the button and onToch looks like this.



public void correctWord(){
correct_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

theWord.setText(((global_rules) getApplication()).NewWord(getApplicationContext()));

}
});
}


public boolean onTouchEvent(MotionEvent event){
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
if(enableTouch) {
holdToView.setVisibility(View.INVISIBLE);
theWord.setVisibility(View.VISIBLE);
}
break;

case MotionEvent.ACTION_MOVE:
break;

case MotionEvent.ACTION_UP:
if(enableTouch) {
holdToView.setVisibility(View.VISIBLE);
theWord.setVisibility(View.INVISIBLE);
}
break;
}
return false;
}


asked 35 secs ago






Aucun commentaire:

Enregistrer un commentaire