Hi all,

  I have a problem when using getSeletedItemId() for a ListActivity.
The code should do something like this:
1. User selects one row of the list.
2. User invokes the menu option "Delete row".
3. onOptionsItemSelected() handles that case and asks for
confirmation:

        case MENU_ID_DEL:
            // Delete row
            rowId = getSelectedItemId();
            if (rowId >= 0) {
                Log.i(TAG, "Deleting row: " + rowId);
                AlertDialog ad = new AlertDialog.Builder(this)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setTitle(R.string.confirm_delete)
                    .setPositiveButton(R.string.yes, new
DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int 
whichButton) {
                                // User clicked Yes so delete the contexts.
                                deleteSelectedRow();
                            }
                        })
                    .setNegativeButton(R.string.no, new
DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int 
whichButton) {
                                // User clicked No so don't delete (do nothing).
                            }
                        })
                    .show();
            }
            return true;

  It is unexpected to me that when calling getSelectedItemId() from
deleteSelectedRow() it returns -9223372036854775808.
  However if I use this code instead it works fine:
        case MENU_ID_DEL:
            // Delete row
           deleteSelectedRow();
            return true;

  Any ideas of my mistake?

  BTW, isn't it inconsistent to have a getSelectedItemId() for the
ListActivity and getSelectedId() for the ExpandableListActivity?

  Thank you for your responses.

  Best regards,

   Jorge
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to