Hello everyone i am trying to create an alert dialog box with 2 buttons in it. one to go back to the main screen and the other to remove an item from my list view and go back to the main screen. I have tried a few methods but none seem to work. Can anyone help please? here is my code.
@Override public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Hello My Name is");
alertDialog.setMessage("" + mNameList.get(position));
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
}
});
alertDialog.setButton2("Remove", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Removed from list", Toast.LENGTH_SHORT).show();
}
});
alertDialog.show();
}
Any help will be appreciated. Thank you in advance!