How to pass data from recyclerview adapter to fragment and what i have to write the code in fragment to receive data.I have already check the links in this website but unfor
You have "ClickListener" in fragment.
for example.
@Override
public void onResume(){
super.onResume();
((ExampleAdapter) mAdapter).onItemClick(new RecyclerViewItemClick() {
@Override
public void onItemClick(int position, View v) {
//to do. ArrayList<> data.get(position).getYourItem();
}
});
}
And you must create interface RecyclerViewItemClick.java
public interface RecyclerViewItemClick {
public void onItemClick(int position, View v);
}
Last. ExampleAdapter.java add
public void onItemClick(RecyclerViewItemClick mclick){
this.myClickListener = mclick;
}
ExampleViewHolder method add in
@Override
public void onClick(View v) {
myClickListener.onItemClick(getAdapterPosition(), v);
notifyDataSetChanged();
}
I hope you solve this problem. Thank.