Saturday, March 8, 2014

Some issues touch event on the touch screen


Hello everyone, recently wrote a program to learn android, encounter problems:


activity has ontouch listener, touching the screen will read the coordinates. When a dialog box pops up when the coordinate value ng ok or meet the requirements, but no response when click OK.

Dialog uses
 new AlertDialog.Builder (Content ()) 
. SetCancelable (true)
. SetTitle ("confirm")
. SetMessage ("OK you?")
. SetPositiveButton ("yes", new android.content.DialogInterface.OnClickListener () {
public void onClick (DialogInterface dialog, int whichButton) {
/ / Cancel button event
}
})


activity using public boolean onTouchEvent (MotionEvent event) read coordinates

Feeling is the key to identify and coordinate conflict pop-up reading. Seeking solutions. Or use another method to write the dialog box? Thank you. We learn together<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
In case there are pop-up box, do not read the coordinates, or read a range OK button, it returns false, this pop-up box will handle the onClick event of it. Otherwise onClick event is onTouchEvent blocked.
Reply:
Can a little too specific?
Reply:
on onTouchEvent return super.onTouchEvent (evt). Your return value is not as true
Reply:
Stay tuned in. . . . . .
Reply:
 @ Override 
public boolean onTouchEvent (MotionEvent event) {
/ / TODO Auto-generated method stub
if (b)
return true;
if (! b && event.getX ()> 80) {
b = true;
new AlertDialog.Builder (this)
. SetCancelable (true)
. SetTitle ("12121")
. SetPositiveButton ("" + event.getX (),
new OnClickListener () {

@ Override
public void onClick (DialogInterface dialog,
int which) {
/ / TODO Auto-generated method stub
b = false;
}
.}) Show ();

}

return super.onTouchEvent (event);
}

Reply:
boolean b = false;
Forget that the

No comments:

Post a Comment