I am trying to learn how to open an activity from a click event inside my adapter.
Right now, I can click a cardview item and send a textview content to a toast thanks to jogarcia, but i cant seem to figure out how to open a new activity and pass the textview content through putExtra()
Here is my adapter code:...
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
final ListItem ListItem = ListItems.get(position);
holder.ConfinedSpaceID.setText(ListItem.getSpaceId());
holder.ConfinedSpaceDescription.setText(ListItem.getDescription());
//the following is added to create an onclick listener for the cardview
holder.cardview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String string;
string = ListItem.getSpaceId().toString();
Toast.makeText(context, "You clicked "+string, Toast.LENGTH_LONG).show();
}
});
}
I want to be able to open a new activity called DisplayIndividual.class, and pass 'string' as a putExtra(). Any help would be appreciated