Esto es lo que he probado, sin obtener los resultados esperados:
private final View.OnItemClickListener itemClickListener = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = null;
switch (position) {
case 0: //search//todo
intent = new Intent(context, Fragment_Tabs.class);
context.startActivity(intent);
break;
}
Y aquí es donde me quedo bloqueado totalmente con el (View v
):
import android.content.Context;
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;
import com.example.javier.MaterialDesignApp.R;
import com.example.javier.MaterialDesignApp.RecyclerView.RecyclerViewClasses.Calendario;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
public class Adapter_Calendario extends RecyclerView.Adapter<Adapter_Calendario.ViewHolder> {
private ArrayList<Calendario> calendario;
Context context;
private final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"Clicked",Toast.LENGTH_SHORT).show();
}
};
// Adapter's Constructor
public Adapter_Calendario(Context context, ArrayList<Calendario> calendario) {
this.calendario = calendario;
this.context = context;
}
// Create new views. This is invoked by the layout manager.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// Create a new view by inflating the row item xml.
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post, parent, false);
v.setOnClickListener(onClickListener);
return new ViewHolder(v);
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
// Set strings to the views
final TextView textViewJornada = (TextView) holder.view.findViewById(R.id.tv_jornada);
final TextView textViewFecha = (TextView) holder.view.findViewById(R.id.tv_fecha);
final TextView textViewHora = (TextView) holder.view.findViewById(R.id.tv_hora);
final TextView textViewEquipo_local = (TextView) holder.view.findViewById(R.id.tv_equipo_local);
final TextView textViewResultado_local = (TextView) holder.view.findViewById(R.id.tv_resultado_local);
final TextView textViewResultado_visitante = (TextView) holder.view.findViewById(R.id.tv_resultado_visitante);
final TextView textViewEquipo_visitante = (TextView) holder.view.findViewById(R.id.tv_equipo_visitante);
final ImageView imageViewEscudo_local = (ImageView) holder.view.findViewById(R.id.tv_escudo_local);
final ImageView imageViewEscudo_visitante = (ImageView) holder.view.findViewById(R.id.tv_escudo_visitante);
textViewJornada.setText("Jornada: "+calendario.get(position).getJornada());
textViewFecha.setText(" El "+calendario.get(position).getFecha()+" ");
textViewHora.setText("A las "+calendario.get(position).getHora()+" ");
textViewEquipo_local.setText(calendario.get(position).getEquipo_local());
textViewResultado_local.setText(" "+calendario.get(position).getResultado_local()+" - ");
textViewResultado_visitante.setText(calendario.get(position).getResultado_visitante()+" ");
textViewEquipo_visitante.setText(calendario.get(position).getEquipo_visitante());
Picasso.with(context).load(calendario.get(position).getEscudo_local())
.placeholder(holder.view.getResources()
//.getDrawable(R.drawable.ic_contact_icon)).transform(new CircleTransform()).into(imageViewImage);
.getDrawable(R.drawable.ic_contact_icon)).into(imageViewEscudo_local);
Picasso.with(context).load(calendario.get(position).getEscudo_visitante())
.placeholder(holder.view.getResources()
//.getDrawable(R.drawable.ic_contact_icon)).transform(new CircleTransform()).into(imageViewImage);
.getDrawable(R.drawable.ic_contact_icon)).into(imageViewEscudo_visitante);
}
// Return the size of your dataset (invoked by the layout manager)
@Override
public int getItemCount() {
return calendario.size();
}
// Provide a reference to the views for each data item
// Complex data items may need more than one view per item, and
// you provide access to all the views for a data item in a view holder
public static class ViewHolder extends RecyclerView.ViewHolder {
// each data item is just a string in this case
public View view;
public ViewHolder(View v) {
super(v);
view = v;
}
}
}