Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code

C#
class RecyclerAdapterMain (val product : ArrayList<modelproductmain>)  : RecyclerView.Adapter<recycleradaptermain.viewholder>() {
    class ViewHolder(itemview: View) : RecyclerView.ViewHolder(itemview) {
        val title : TextView = itemview.product_txt
        val price : TextView = itemview.price_product
        val imageproduct : ImageView = itemview.product_image
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {

       val view = LayoutInflater.from(parent.context).inflate(R.layout.product_items , parent , false)

        return ViewHolder(view)
    }

    override fun getItemCount() = product.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {

        val products = product[position]

        holder.title.text = products.title
        holder.price.text = products.price.toString()
            }
        }
    }


What I have tried:

i use support fragment manager to change between fragments it was ok but when i want to pass data with bundle it send the null parameter .\

anyone can help with this ?...
Posted
Updated 17-Aug-20 2:33am
v2

1 solution

You can pass data by attaching a callback into your adapter. Steps:
1. Create an interface
2. Delegate the callback
3. Implement the fragment with the interface
Here, have a look at this: java - How to pass or send data from recyclerview adapter to fragment - Stack Overflow[^]

Few more on similar discussions:
java - How to pass data from Recyclerview to Fragment - Stack Overflow[^]
android - I want to send data from recyclerview adapter from fragment to fragment opening new fragment - Stack Overflow[^]
android - Pass the data from Recyclerview adapter to Fragment - Stack Overflow[^]

Believe it should help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900