I have an AlertDialog in android that contains a list of buddies from sqlite. When I click on the buddy name in the list, that buddy is called. What I want to do is add a longclicklistener to the list as well so I can be prompted to delete the buddies in the list. I am having trouble having onlclick and onlongclick work on the same element. Can someone give me a pointer here. I have been working with android for a few months. Thanks for any help!
private void displayBuddyList(String region) {
final String region2 = region;
Context context = getApplicationContext();
dh = new DataBaseHelper(context);
List<String> bnames = dh.selectBuddies();
Log.d(TAG, "Buddy Names: " +bnames);
final CharSequence[] buds = bnames.toArray(new CharSequence[bnames.size()]);
// final CharSequence[] items = {"Mark", "Vikrant", "Olle,"Jane","Dan"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Select a Buddy");
builder.setItems(buds, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int item) {
// showShortToast("Clicked on:"+buddy[item]);
String ptcode = buds[item].toString();;
if (region2 == "A") {
callbuddy(ptcode,region2);
} else if (region2 == "E") {
callbuddy(ptcode,region2);
} else if (region2 == "P") {
callbuddy(ptcode,region2);
} else {
showShortToast("We have a bug");
}
return;
}
});
builder.create().show();
}