//此方法绑定列表上的数据
override fun onBindViewHolder(holder: CustomAdapter.ViewHolder, position: Int) {
holder.bindItems(userList[position])
holder.imgDelete.setOnClickListener(View.OnClickListener {
Toast.makeText(this,"Delete Button Clicked", Toast.LENGTH_SHORT).show()
})
holder.imgCopy.setOnClickListener(View.OnClickListener {
Toast.makeText(this,"Copy Button Clicked", Toast.LENGTH_SHORT).show()
})
}
错误得到:-以下任何一个函数都不能用提供的参数调用: public open fun makeText(p0:Context !, p1:CharSequence !, p2:Int):吐司!在android.widget.Toast中定义
请检查并帮助
采用
代替
I think, the Application context, used here should be the activity class context, instead of
this
, becausethis
inside an onClickListener, is actually not a applicationContext to the activity but that of the parent view.尝试这个:
不要忘记用您自己的内容替换这里的活动上下文。