How to make BaseAdapter show AlertDialog android Application

后端 未结 4 1161
旧时难觅i
旧时难觅i 2021-01-22 11:09

How can I make the button in BaseAdapter in listView shows alertDialog, I tried that but it Stopped work unexpected (RunTime Error) my code is shown below .

any suggesti

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-22 11:28

        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getRootView().getContext());
        alertDialogBuilder.setMessage("Are you sure you want to delete?");
        alertDialogBuilder.setPositiveButton("Ok",
                new DialogInterface.OnClickListener() {
    
                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        deleteExp(tid);
                    }
                });
    
        alertDialogBuilder.setNegativeButton("cancel",
                new DialogInterface.OnClickListener() {
    
                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
    
                    }
                });
    
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    

提交回复
热议问题