Skip to content Skip to sidebar Skip to footer

How To Dismiss Custom Alert Dialog

i have a Custom Alert Dialog , i have a imageView For close Dialog but i don`t know how to do it. I try to do it by dismiss or cancel, but it does not work public void onC

Solution 1:

Try Like this create AlertDialog form AlertDialog.Builder.

 AlertDialog.Builder dialog = new AlertDialog.Builder(context);
    final View viewLayout = mInflater.inflate(R.layout.listview_addstudent_items , null);
    dialog.setView(viewLayout);
    ImageView closeIcon_img = (ImageView)viewLayout.findViewById(R.id.item_img_close);
    final AlertDialog  alertDialog=dialog.create();
    closeIcon_img.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();

Post a Comment for "How To Dismiss Custom Alert Dialog"