1 AlertDialog dialog = new AlertDialog.Builder(this).create(); 2 dialog.setTitle("对话框"); 3 dialog.setIcon(R.drawable.ic_launcher); 4 dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确认", new DialogInterface.OnClickListener() { 5 6 @Override 7 public void onClick(DialogInterface dialog, int which) { 8 String s = data.get(pos); 9 10 data.remove(pos);11 data.add(0, s);12 13 mAdapter.notifyDataSetChanged();14 15 Toast.makeText(getApplicationContext(), "已确认!", 0).show();16 }17 });18 19 dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener() {20 21 @Override22 public void onClick(DialogInterface dialog, int which) {23 String s = data.get(pos);24 25 Toast.makeText(getApplicationContext(), "已取消!", 0).show();26 }27 });28 dialog.show();
原标题:点击事件的确认取消对话框。
关键词: