Ok, so the code below started working as soon as I switched from getApplicationContext (which I thought was safe here) to SmsDecorator.this.
I've been a little confused about which to use where for a while. Can anyone please clarify the differences and where it it best to use one over the other?? Thanks. On Aug 28, 3:24 pm, eags <eagsala...@gmail.com> wrote: > 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 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 -~----------~----~----~----~------~----~------~--~---