Skip to content

not working in recyclerview adapter #4

@karthi72

Description

@karthi72

I just integrated the code to my recycler view adapter and there I cant able to handle single item click submit after selection.

class ProductsAdapter : RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MovieViewHolder {

    val inflater = LayoutInflater.from(parent.context)

    return MovieViewHolder(inflater, parent)

}
override fun onBindViewHolder(holder: MovieViewHolder, position: Int) {
    holder.bind()
}

override fun getItemCount(): Int = 10}

class MovieViewHolder(inflater: LayoutInflater, parent: ViewGroup) :
RecyclerView.ViewHolder(inflater.inflate(R.layout.item_product, parent, false)),
OnStateListener {
private var mTitleView: TextView? = null
private var mIncrementProductView: IncrementProductView? = null

init {
    mTitleView = itemView.findViewById(R.id.amount)
}

override fun onCountChange(count: Int) {

    mTitleView?.text = "$" + count * 45;
}

override fun onConfirm(count: Int) {
    Toast.makeText(itemView.context, "Confirm Count : $count", Toast.LENGTH_SHORT).show()
}

override fun onClose() {
    Toast.makeText(itemView.context, "Close Action", Toast.LENGTH_SHORT).show()
}

fun bind() {
    mTitleView?.text = "23"
    mIncrementProductView?.setOnStateListener(this)

    mIncrementProductView?.setOnClickListener {
        Toast.makeText(
            itemView.context,
            "Position clicked $adapterPosition",
            Toast.LENGTH_SHORT
        ).show()
    }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions