我在此行代码中显示此错误:
quantityFragment.show(fragManager, "Quantity")
以下任何函数均不能使用提供的参数来调用。 在com.company.kotlinecommerce.QuantityFragment中定义的show(FragmentManager !, String!) com.company.kotlinecommerce.QuantityFragment
中定义的show(FragmentTransaction !, String!)
ProductAdapter.kt
itemView.bAddToCart.setOnClickListener {
UserInfo.tempProdId = tempProdId
// Show the fragment
var quantityFragment = QuantityFragment()
var fragManager = (itemView.context as Activity).fragmentManager
quantityFragment.show(fragManager, "Quantity")
}
QuantityFragment.kt
class QuantityFragment : DialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_quantity, container, false)
}
}
请帮帮我^ _ ^
答案 0 :(得分:0)
您正在使用android.support.v4.app.DialogFragment
,因此我们需要传递supportFragmentManager
而不是将fragmentManager
传递给show方法