Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working in recyclerview adapter #4

Open
karthi72 opened this issue May 14, 2020 · 0 comments
Open

not working in recyclerview adapter #4

karthi72 opened this issue May 14, 2020 · 0 comments

Comments

@karthi72
Copy link

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()
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant