I need my RecyclerView
Image can be pressed and go to next activity. I have the Adapter
code.
public class MakananAdapter extends RecyclerView.Adapter<MakananAdapter.ViewHolder> {
ArrayList<Makanan> makananList;
public MakananAdapter(ArrayList<Makanan> makananList)
{
this.makananList = makananList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list,parent,false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Makanan tanaman = makananList.get(position);
holder.tvJudul.setText(tanaman.judul);
/*holder.tvHarga.setText(tanaman.harga);*/
holder.ivFoto.setImageDrawable(tanaman.foto);
holder.tvJudul.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
@Override
public int getItemCount() {
if(makananList!=null)
return makananList.size();
return 0;
}
public class ViewHolder extends RecyclerView.ViewHolder {
ImageView ivFoto;
TextView tvJudul;
TextView tvHarga;
public ViewHolder(View itemView) {
super(itemView);
ivFoto = (ImageView) itemView.findViewById(R.id.imageView);
tvJudul = (TextView) itemView.findViewById(R.id.textViewJudul);
/*tvHarga = (TextView) itemView.findViewById(R.id.textViewHarga);*/
}
}}
How to Intent RecyclerView in AdapterClass?