I figured this out so I thought I would share.  The handleKeyPress
method that is called from my OnKey handler is part of my Activity
object.  So "this" is an activity not a dialog.  So to get the focused
item is pretty simple, I needed to keep a reference to the AlertDialog
(mAlertDialog in the example):

public boolean handleKeyPress(DialogInterface dialog, int keyCode,
KeyEvent event) {

 ListView lv = mAlertDialog.getListView();
 if( lv != null ) {
     int selectedPos = lv.getSelectedItemPosition();
     Log.d("keyPress", "handleKeyPress : selectedPos: " +
selectedPos);
 }

You also have to test for the right key and only choose the down
button action, but this is the part I had trouble with.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to