Android Studio 3.1。 Android minSdkVersion 18,Java 1.8
这是我的DialogFragment:
public class ReceiptDialogFragment extends DialogFragment {
public interface DialogListener {
public void onClickClose(DialogFragment dialog);
}
public void setDialogListener(DialogListener dialogListener) {
this.dialogListener = dialogListener;
}
}
这是我的活动:
@Override
public void showReceiptDialog(String message) {
ReceiptDialogFragment receiptDialogFragment = new ReceiptDialogFragment();
receiptDialogFragment.setDialogListener(dialog -> dialog.dismiss());
receiptDialogFragment.show(getSupportFragmentManager(),
ReceiptDialogFragment.class.getName());
}
好。很好 但是Android Studio的方法:
receiptDialogFragment.setDialogListener(dialog -> dialog.dismiss());
显示提示消息
Can be replaced with method reference
我尝试使用像这样的方法引用:
receiptDialogFragment.setDialogListener(receiptDialogFragment::dismiss());
但是我收到错误编译错误:
Can not resolve method `dismiss`
为什么?