android - Prevent multiple button presses on AlertDialog -
i have simple alertdialog responding multiple buttons being pressed @ same time. instance, there yes , no button, , if user uses 2 fingers press both @ once, both yes , no onclicklisteners triggered , code run. i've seen mention of android:splitmotionevents="false", using default alertbuilder without added view , doesn't appear there way set it. try creating timestamp, seems hack , expect there in android code allow handled already.
here code:
alertdialog.builder builder = new alertdialog.builder(testactivity.this); builder.settitle(r.string.title) .setmessage(getstring(r.string.message)) .setcancelable(false) .setpositivebutton(r.string.yes, new android.content.dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { runtest(false); } }) .setneutralbutton(r.string.no, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { runtest(true); } }) .setnegativebutton(r.string.cancel, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { // nothing } }); alertdialog dialog = builder.create();
i have feeling have style resource dialog
just add
<item name="android:splitmotionevents">false</item>
to dialog style. prevent multi-touch dialogs using it.
Comments
Post a Comment