show confirmation dialog java android

Solutions on MaxInterview for show confirmation dialog java android by the best coders in the world

showing results for - "show confirmation dialog java android"
Ester
22 Nov 2020
1public void onDeleteClick(View v) {
2    int i = Integer.parseInt((String)v.getTag());
3
4    AlertDialog.Builder alert = new AlertDialog.Builder(AddressListActivity.this);
5    alert.setTitle("Delete");
6    alert.setMessage("Are you sure you want to delete?");
7    alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
8
9        @Override
10        public void onClick(DialogInterface dialog, int which) {
11            Address address = _list.get(_currentPage*PANELS_PER_PAGE + i);
12            _dbAdapter.deleteAddress(address.Id);
13
14            _GetAddresses();
15
16            dialog.dismiss();
17        }
18    });
19
20    alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
21
22        @Override
23        public void onClick(DialogInterface dialog, int which) {
24                dialog.dismiss();
25        }
26    });
27
28    alert.show();
29}
30