public interface OnItemClickListener<VH extends RecyclerView.ViewHolder, E> {
void onItemClick(RecyclerView<VH> parent, VH viewHolder, int position, E item);
}
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView cityName;
public ViewHolder(View view) {
super(view);
cityName = (TextView) view.findViewById(R.id.city_name);
itemView.setOnClickListener(this); // bind the listener
}
@Override
public void onClick(View view) {
clickListener.onClick(view, getPosition()); // call the onClick in the OnItemClickListener
}
}