Carried MotionEvent.ACTION_MOVE: operation, and then meet certain conditions (such as Event.getX> 50). Then pop-up dialog: Pass
For example, when you move the process through had 10 points to meet the conditions, 10 times the dialog will pop up, how let him meet the first condition: problems encountered pop-up dialog A dialog box will pop up, do not do judgment behind?
Thank you. . . .<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Records about the state of the pop-up dialog, a dialog box before the judge to look at each state, if you have played and are no longer playing.
Reply:
I use AlertDialog.Builder builder dialog box pops up, how to record status, whether similar
if (! AlertDialog.Builder builder) and the like? Did not so do java, not very clear. Thank you. . .
Reply:

Reply:
Defined
private boolean flag = true;
Method in the MotionEvent.ACTION_MOVE
if (flag) {
flag = false;
/ / Pop-up dialog
}
In MotionEvent.ACTION_UP method where then flag assignment was true.
Reply:
The code:
case MotionEvent.ACTION_MOVE:
{
rec.x = event.getX ();
rec.y = event.getY ();
rec.size = event.getSize ();
int nh = event.getHistorySize ();
for (int h = 0; hfloat hx = event.getHistoricalX (h);
float hy = event.getHistoricalY (h);
addPoint (rec, hx, hy);
}
addPoint (rec, rec.x, rec.y);
}
if (flag) {
if (rec.y> ((sh-32) * 2 +64) / 4f-16 && rec.y <((sh-32) * 2 +64) / 4f +16)
{
flag = false;
new AlertDialog.Builder (getContext ())
. SetCancelable (true)
. SetTitle ("Test Results")
. SetMessage ("2.5mm:! Fail")
. SetPositiveButton ("OK", new android.content.DialogInterface.OnClickListener () {
public void onClick (DialogInterface dialog, int whichButton) {
/ / Cancel button event
dialog.dismiss ();
}
})
. Show ();
}
}
Touch the future there will be a prompt box, then an application error occurs, to help analyze. . Thank you.
Reply:
Error log made up.
Reply:
This code is no problem, I have already been verified. Add two points:
1 In MotionEvent.ACTION_UP method where then flag assigned to true.
Direct return true 2.MotionEvent.ACTION_MOVE the case after treatment finished.
Reply:
10-25 11:03:19.948: W / dalvikvm (14654): threadid = 1: thread exiting with uncaught exception (group = 0x2aac8578)
10-25 11:03:19.948: E / AndroidRuntime (14654): FATAL EXCEPTION: main
10-25 11:03:19.948: E / AndroidRuntime (14654): java.lang.IllegalArgumentException: Can't post updates without LOOPED_TICKER set
10-25 11:03:19.948: E / AndroidRuntime (14654): at org.hermit.android.core.SurfaceRunner.postUpdate (SurfaceRunner.java: 523)
10-25 11:03:19.948: E / AndroidRuntime (14654): at org.hermit.touchtest.StGridView2.onTouchEvent (StGridView2.java: 136)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.view.View.dispatchTouchEvent (View.java: 3952)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java: 1034)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java: 1034)
10-25 11:03:19.948: E / AndroidRuntime (14654): at com.android.internal.policy.impl.PhoneWindow $ DecorView.superDispatchTouchEvent (PhoneWindow.java: 1691)
10-25 11:03:19.948: E / AndroidRuntime (14654): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java: 1125)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.app.Activity.dispatchTouchEvent (Activity.java: 2096)
10-25 11:03:19.948: E / AndroidRuntime (14654): at com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchTouchEvent (PhoneWindow.java: 1675)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.view.ViewRoot.deliverPointerEvent (ViewRoot.java: 2219)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.view.ViewRoot.handleMessage (ViewRoot.java: 1903)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.os.Handler.dispatchMessage (Handler.java: 99)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.os.Looper.loop (Looper.java: 138)
10-25 11:03:19.948: E / AndroidRuntime (14654): at android.app.ActivityThread.main (ActivityThread.java: 3701)
10-25 11:03:19.948: E / AndroidRuntime (14654): at java.lang.reflect.Method.invokeNative (Native Method)
10-25 11:03:19.948: E / AndroidRuntime (14654): at java.lang.reflect.Method.invoke (Method.java: 507)
10-25 11:03:19.948: E / AndroidRuntime (14654): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 878)
10-25 11:03:19.948: E / AndroidRuntime (14654): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 636)
10-25 11:03:19.948: E / AndroidRuntime (14654): at dalvik.system.NativeStart.main (Native Method)
Reply:
I think the reason is that every move when, in rec.y meet the conditions of many of the points are pop-up dialog box, resulting in data caused by gambling plug.
Reply:
Now every move a pop-up box will pop up ah. See log like this is the problem.
You can try to put if (flag) to advance to the case MotionEvent.ACTION_MOVE: the place to start.
Reply:
Oh, thank you for your patience reply. CSDN found this place really is not much enthusiastic person. . . Chit'd kicked a bunch of people in the workplace more. . . . .
Reply:
Get a global boolean or int value judgment on ok, stop the role play
Reply:
"OK" button, there appears a button, and then appeared again, looks like a dot on the number of responses pop a few.
Reply:
You send me the code has already been verified ah, specifically to see the 7th floor, did not you say a problem.
Why do not you send the full activity, I see.
Reply:
Oh, have to get is the other java short cycle call causes, tantahe positive solution, affixed to the end points.

No comments:
Post a Comment