You've got an ArrayList for example:
list = new ArrayList<Obj>();
list.add(new Obj(R.drawable.img, "string", "na, na, na"));
list.add(new Obj(R.drawable.ima2, "string 2", "Na, na, na"));
list.add(new Obj(R.drawable.img3, "string 3", "Na, na, na"));
...
this List inflates into a RecyclerView
.
When I click a RecyclerView
Item, I want to pass only the element of the list I have clicked on to another Activity, not the whole List.
How do I do it?
This is what I have tried so far:
ItemClickSupport.addTo(recyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener(){
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
Intent intent = new Intent(ChordsListActivity.this, ChordActivity.class);
intent.putExtra("selected", list);
startActivity(intent);
}
});