add listener to listview in dialog

by zcj0429 » Tue, 06 Jan 2009 11:44:51 GMT

Sponsored Links
   I'm now create a listview in a dialog. But I don't know how to
detected if an item is clicked. Then background activity is
"PreferenceActivity", and the "onListItemClick" method seems not work.
Here is the relevant code:
public void changeConnPref() {
                conns = new ArrayList<String>();
                mDialog = new Dialog(this);
                mDialog.setTitle("Connection Preference");
                bConnAdapter = new ConnAdapter(conns, mDialog.getContext());
                ListView dlv = (ListView) mDialog.findViewById(;

                Button bOk = (Button) mDialog.findViewById(;
                bOk.setOnClickListener(new OnClickListener() {
                        public void onClick(final View v) {


                Button bCancel = (Button) mDialog.findViewById(;
                bCancel.setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {

Can anyone help?

Other Threads

1. Problem Running App

Hi, I've created an Android app with the Eclipse SDK, but when I try
to run it, the emulator opens, but the app never opens. On the Eclipse
console it says:

[2008-07-04 11:54:09 - VideoPlayer] New emulator found: emulator-
[2008-07-04 11:54:42 - VideoPlayer] HOME is up on device 'emulator-
[2008-07-04 11:54:42 - VideoPlayer] Pushing VideoPlayer.apk to /data/
app on device 'emulator-tcp-5555'
[2008-07-04 11:54:48 - VideoPlayer] Failed to install VideoPlayer.apk
on 'emulator-tcp-5555': timeout

What's wrong?


2. Troubleshooting----installing android plug in to eclipse

# From the dialog where you select the Update sites to visit, select
the checkboxes for both the ADT site, and the Callisto/Europa/Ganymede
Discovery Site (you may want to check Automatically select mirrors at
the bottom).
# Click Finish.
# In the Next dialog, select the Android Plugins.
# Now, expand the tree item of the discovery site. It seems that if
you don't do it, it doesn't load the content of the discovery site.
# On the right, click Select required. This will select all the
components that are required to install the Android plugin (wst, emf,
# Click Next, accept the agreement, click Install All, and restart

you MUST check Automatically select mirrors at the bottom......


3. Problem Running My App

4. Android security application developing in Boston


6. Can Android be easily ported to ARM11 MPCore?

7. problem in adding animation to imageview