I'm trying to pop up an AlertDialog when someone long presses a list
item. What I end up with is nested callback objects. I'm not sure if
that is the problem but simple Alert dialog examples are not working
for me. Here is what I want and is crashing:
smsContactsListView.setOnItemLongClickListener(new
OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent,
View view,
int position, final long id) {
new AlertDialog.Builder(getApplicationContext())
.setTitle("Alert")
.setMessage("Really Delete SMS Contact?")
.setPositiveButton("Ok", new
DialogInterface.OnClickListener
() {
@Override
public void onClick(DialogInterface
dialog, int which) {
dbAdapter.removeSmsContact(id);
smsContactsCursor.requery();
}
})
.setPositiveButton("Cancel", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface
dialog, int which) {
}
})
.show();
// return true to indicate we consumed the callback
return true;
}
});
Here is what works (no dialog at all):
smsContactsListView.setOnItemLongClickListener(new
OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent,
View view,
int position, final long id) {
// This works for now
dbAdapter.removeSmsContact(id);
smsContactsCursor.requery();
// return true to indicate we consumed the callback
return true;
}
});
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---