Hi Vincent
That‘s a good idea , as we know, if we build an alterDlg need following
code
//modify by mercury xu 20090314 in the new sdk
//they don't support this function as showAlert!
new AlertDialog.Builder(loginScreen.this)
.setTitle("Login Data")
.setMessage("Login :" + usrTxt + "\n"+ "PassWords : " + pwdTxt)
.setIcon(R.drawable.icon)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
setResult(RESULT_OK);
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
})
.show();
maybe you can try to change the setPositiveButton and setNegativeButton
as Not visible or comment them, and add following code for keyup or keydown
founction.
OnClickListener as setResult(RESULT_OK);
finish();
you can get some useful infomation from
http://developer.android.com/reference/android/app/AlertDialog.html.
boolean
onKeyDown<http://developer.android.com/reference/android/app/AlertDialog.html#onKeyDown%28int,%20android.view.KeyEvent%29>(int
keyCode,
KeyEvent<http://developer.android.com/reference/android/view/KeyEvent.html>event)
A
key was pressed down.
boolean
onKeyUp<http://developer.android.com/reference/android/app/AlertDialog.html#onKeyUp%28int,%20android.view.KeyEvent%29>(int
keyCode,
KeyEvent<http://developer.android.com/reference/android/view/KeyEvent.html>event)
A
key was released.
those two founction I hope that is your need.
Wish good luck and best regards!
Mercury
2009/3/15 vincent Kor <[email protected]>
>
>
> Hi, All:
>
> from the reference of SDK, AlertDialog information as below.
>
> I want to create a dialog but i don't want to have any buttons in the
> dialog, then i hope to dismiss the dialog after i click any item in the
> dialog, how should i dismiss the dialog ?
>
> When the user click the "back" button, it will dismiss the dialog. so
> i need to send the key message in hard code ? is there any other way??
>
> Thanks a lot for your help.
>
> Vincent
>
>
> ----------------------------------
> public
> AlertDialog.Builder<http://developer.android.com/reference/android/app/AlertDialog.Builder.html>
> setSingleChoiceItems
> (CharSequence[]<http://developer.android.com/reference/java/lang/CharSequence.html>items,
> int checkedItem,
> DialogInterface.OnClickListener<http://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html>listener)
>
> Set a list of items to be displayed in the dialog as the content, you will
> be notified of the selected item via the supplied listener. The list will
> have a check mark displayed to the right of the text for the checked item.
> Clicking on an item in the list will not dismiss the dialog. Clicking on a
> button will dismiss the dialog.
> Parameters items the items to be displayed. checkedItem specifies
> which item is checked. If -1 no items are checked. listener
>
> notified when an item on the list is clicked. The dialog will not be
> dismissed when an item is clicked. It will only be dismissed if clicked on a
> button, *if no buttons are supplied it's up to the user to dismiss the
> dialog. *
>
> **
>
> -----------------
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---