在BottomsheetDialog中使用setcontentview时,会出现类似“以下函数都不能用提供的参数调用”的错误

我试图在我的片段中实现BottomsheetDialog。 但是当我尝试调用bottomSheetDialog.setContentView(view)的错误

以下任何函数都不能用在android.support.design.widget.BottomSheetDialog中定义的android.support.design.widget.BottomSheetDialog中定义的setContentView(View!)参数来调用setContentView(Int)

当我用Java代码实现它时,它完美的工作。 但是当试图用Kotlin实现这个错误时,

提供我用Kotlin试过的代码,

 private fun showRenewDialog(renewModel: RenewModel?) { if (bottomSheetDialog == null) bottomSheetDialog = BottomSheetDialog(activity) val view:View? = activity.getLayoutInflater().inflate(R.layout.renewal_dialog, null, false) bottomSheetDialog.setContentView(view) } 

与Java相同的代码

 if (bottomSheetDialog == null) bottomSheetDialog = new BottomSheetDialog(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.book_dialog, null, false); bottomSheetDialog.setContentView(view); 

嗨,在你的Kotlin Code中,你不需要通过paramas就可以用这个,

  fun openBottomSheetDialog() { val dialog = BottomSheetDialog(this@YOUR_CLASS_NAME) // if it is a activity than @DetailActivity dialog.setContentView(R.layout.book_dialog) dialog.show() }