add listener to listview in dialog

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


Sponsored Links
 Hi:
   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>();
                conns.add("WIFI");
                conns.add("Bluetooth");
                mDialog = new Dialog(this);
                mDialog.setContentView(R.layout.connpreference);
                mDialog.setTitle("Connection Preference");
                bConnAdapter = new ConnAdapter(conns, mDialog.getContext());
                ListView dlv = (ListView) mDialog.findViewById(R.id.conn_list);
                dlv.setAdapter(bConnAdapter);

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

                                mDialog.dismiss();
                        }
                });

                Button bCancel = (Button) mDialog.findViewById(R.id.pre_cancel);
                bCancel.setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                                mDialog.cancel();
                        }
                });
}
--------------------------------------------------------------------------------------------------------------

Can anyone help?
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Change CharSet

Hello,
how i can change the charset for my app.?

I wonna use ISO-8859-1 for all Input!

rgds Mr.No
--~--~---------~--~----~------------~-------~--~----~

2. Permission Denied Error

Hello,

Is there any reason why my application is getting  a permission denial
message for BOOT_COMPLETED ? I have included <uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> in my
AndroidManifest.xml file.
WARN/ActivityManager(515): Permission Denial: receiving Intent {
action=android.intent.action.BOOT_COMPLETED } from android requires
android.permission.RECEIVE_BOOT_COMPLETED

-- 
Thanks,
Jaikishan

--~--~---------~--~----~------------~-------~--~----~

3. Webview and language support

4. why print android_power:wakeup and didn't boot?

5. Enhancements to Android

6. semaphore

7. Is Market developer console updating in real time?