我希望 onclicklistener 方法打开与对象相关的活动:entidad1、entidad2 或 entidad3。
MainActivity.java 上的 OnRecipe 方法,如果 entidad1 出现,它会带我到 x 活动,如果 entidad2 出现在 y 活动等,关于如何做的任何想法,因为现在它需要我所有entidad1 活动的时间。我想这一定与使用优先级来决定打开哪个而不是位置有关。
那是我的适配器:
package com.test.platos_4;
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.RatingBar;
import android.widget.TextView;
import java.util.List;
public class Adaptador2 extends RecyclerView.Adapter<Adaptador2.ViewHolder>
{
private List<Entidad2> listItems;
private OnRecipeListener mOnRecipeListener;
public Adaptador2(List<Entidad2> listItems, OnRecipeListener onRecipeListener) {
this.listItems = listItems;
this.mOnRecipeListener = onRecipeListener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.elemento_lista2, parent, false);
return new ViewHolder(view, mOnRecipeListener);
}
@Override
public void onBindViewHolder(ViewHolder viewholder, int position) {
int resource = listItems.get(position).getImgFoto();
String title = listItems.get(position).getTitulo();
String time = listItems.get(position).getTiempo();
int barra = listItems.get(position).getRating();
//int fondo = listItems.get(position).getColorfondo();
viewholder.setData(resource, title, time, barra);
// por si necesito color de fondo viewholder.setData(resource, title, time, barra, fondo);
}
@Override
public int getItemCount() {
return listItems.size();
}
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private ImageView imgFoto;
private TextView titulo;
private TextView tiempo;
private RatingBar ratingBar;
}
UYOU
相关分类