Recently, we found that adding a click event listener to the button will pop up a dialog box in the listener event. If the mobile phone response is slow, more than one will pop up and many posts will be searched online, it is not very suitable.
In the end, I implemented it in a stupid way:
OnClickListener infoClick = new OnClickListener (){
Public void onClick (View v ){
If (! IsClick ){
IsClick = true;
OpenInfoWindow ();
}
}
};
Defines an isClick variable. When you click it, set it to true. When you close the dialog box, set isClick to false.
And then click "back" to cancel the operation:
Alertdialog. setOnKeyListener (new backlistener ());
Class backlistener implements OnKeyListener {
Public boolean onKey (DialogInterface dialog, int keyCode, KeyEvent event ){
If (keyCode = KeyEvent. KEYCODE_BACK)
{
If (isClick ){
TipsUtil. closeAlertDialog ();
}
IsClick = false;
Return true;
}
Return false;
}
}
The setOnKeyListener listener is returned for setting the dialog box.
Author "stulpnn"