What i'm basically trying to do is make the objects that show up in the recycler view clickable to a certain TextView id because i'm making a program that shows an album cover and its title next to it in a list. I need to be able to click on each one of the boxes that the recycler view makes and have a TextView pop up with the other information (author, published date, hit songs, etc) when its clicked on and then a back button (if possible) to go back to the album list. I've been looking at this for hours and cant figure out how to make an OnclickListener work for it. If you know how or have any suggestions id be glad to hear them. Thank you!
package com.albumlist.albumlist;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
private AlbumData[] itemsData;
public MyAdapter(AlbumData[] itemsData){
this.itemsData = itemsData;
}
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView txtViewTitle;
private ImageView imgViewIcon;
public ViewHolder(View itemLayoutView) {
super(itemLayoutView);
itemLayoutView.setOnClickListener(this);
txtViewTitle = (TextView) itemLayoutView.findViewById(R.id.album_title);
imgViewIcon = (ImageView) itemLayoutView.findViewById(R.id.album_icon);
}
@Override
public void onClick(View v) {
}
}
@Override
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
View itemLayoutView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.data_layout, null);
ViewHolder viewHolder = new ViewHolder(itemLayoutView);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
viewHolder.txtViewTitle.setText(itemsData[position].getTitle());
viewHolder.imgViewIcon.setImageResource(itemsData[position].getImageUrl());
}
@Override
public int getItemCount() {
return itemsData.length;
}
}