IllegalStateException( “You can not set Dialog's OnCancelListener or OnDismissListener”)

后端 未结 4 1694
独厮守ぢ
独厮守ぢ 2020-12-16 09:41

This DialogFragment implementation causes an

IllegalStateException( \"You can not set Dialog\'s OnCancelListener or OnDismissListener\")

4条回答
  •  旧巷少年郎
    2020-12-16 10:00

    Try this code i hope this will be work..

    AlertDialog.Builder builder = new AlertDialog.Builder(
                class_name.this);
        builder.setTitle("Title");      
        AlertDialog dialog = builder.create();
        dialog.setButton("ok", new DialogInterface.OnClickListener() {
    
            public void onClick(DialogInterface dialog, int which) {            
    
        });
    
    
        dialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
    
            @Override
            public void onClick(DialogInterface dialog, int which) {
    
    
                dialog.cancel();
    
            }
        });
        dialog.show();
    

提交回复
热议问题