gpt4 book ai didi

android - Android Kotlin-对话框 fragment 错误(以下任何函数均不能使用提供的参数来调用)

转载 作者:行者123 更新时间:2023-12-02 13:22:28 25 4
gpt4 key购买 nike

我在代码的这一行显示此错误:

 quantityFragment.show(fragManager, "Quantity")

None of the following functions can be called with the arguments supplied. show(FragmentManager!, String!) defined in com.company.kotlinecommerce.QuantityFragment show(FragmentTransaction!, String!) defined in com.company.kotlinecommerce.QuantityFragment



产品适配器
        itemView.bAddToCart.setOnClickListener {
UserInfo.tempProdId = tempProdId

// Show the fragment

var quantityFragment = QuantityFragment()
var fragManager = (itemView.context as Activity).fragmentManager

quantityFragment.show(fragManager, "Quantity")

}

数量片段
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)
}
}

请帮帮我^ _ ^

最佳答案

您正在使用android.support.v4.app.DialogFragment,因此我们需要传递supportFragmentManager而不是将fragmentManager传递给show方法

关于android - Android Kotlin-对话框 fragment 错误(以下任何函数均不能使用提供的参数来调用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52576555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com