How to dismiss the AlertDialog without buttons after clicking on any item in the Alert Dialog

by vincent Kor » Sun, 15 Mar 2009 20:22:03 GMT

Sponsored Links
 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??

    Really appreciate your help !!


AlertDialog.Builder<> ;
(CharSequence[]<> ;items,
int checkedItem,
DialogInterface.OnClickListener<> ;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 *


Other Threads

1. SharedPreferences editor commit() returning false

My code looks something like this:

SharedPreferences myPrefs = getPreferences(MODE_PRIVATE);

Note that the key/value pair Some_String/someInt does not exist in
preferences.xml and I presume the editor should create it. Perhaps
that presumption is wrong and that's why the commit is failing? If so,
how do I create a new key/value pair in the preferences, one that is
not visible to the user? Do I need to create a separate preferences
file for that purpose or will the default one support that?


2. Query sent SMS from content provider

Hello, when I send an SMS on my emulator, it goes to the content
content: //sms/sent


So I want to get these SMS's sent, which are in the content provider.
But I do not know how to do this. I know I should have the query ()
method and then call it in the place where I want to search. I did

ContentResolver cr = getContentResolver ();// Getting object
final Uri CONTENT_URI Uri.parse = ("content://sms/sent");
public void myClickHandler (View view) (

        switch (view.getId ()) {

            cr.query (CONTENT_URI, null, null, null, null);



Once I have done a search, how do I list it in a ListView?
Could someone help me in detail? If you can, thank you.


3. Query sent SMS in content provider

4. Query sent SMS fro

5. From iphone to Android: SMS history recover

6. Checking for App before Launching

7. Quick test with log from a Samsung Moment user please?