I wrote in the adapter to RecyclerView onClick , but it turns out that the action is transmitted to every 15th element ... What is the problem? And how can I, after clicking on CardView correctly pull up more data on the Id element of the DataForecast.DataBean class and shove? thank
public class ForecastAdapter extends RecyclerView.Adapter<ForecastAdapter.ForecastViewHolder> { private List<DataForecast.DataBean> list; public ForecastAdapter(List<DataForecast.DataBean> list) { this.list = list; } private List<GetDescriptionForecastModel> descrption; @Override public ForecastViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.listitem_forecast, parent, false); return new ForecastViewHolder(view); } @Override public void onBindViewHolder(ForecastViewHolder holder, int position) { DataForecast.DataBean searchModel = list.get(position); holder.timedate.setText(searchModel.getDate()); holder.game.setText(searchModel.getCommand()); holder.forecast.setText("Фора1 по очкам (-4.5) @ " + searchModel.getKf()); //GetDescriptionForecastModel searchDescription = descrption.get(position); -- это дополнительные данные из другого класса которые мне нужны после onClick //holder.about.setText(searchDescription.getData()); } @Override public int getItemCount() { return list.size(); } public class ForecastViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { TextView timedate, game, forecast, score, about; CardView cv_forecast; public ForecastViewHolder(View itemView) { super(itemView); itemView.setOnClickListener(this); timedate = (TextView) itemView.findViewById(R.id.txt_forecast_timedate); game = (TextView) itemView.findViewById(R.id.txt_forecast_game); forecast = (TextView) itemView.findViewById(R.id.txt_forecast_forecast); score = (TextView) itemView.findViewById(R.id.txt_forecast_score); about = (TextView) itemView.findViewById(R.id.forecast_txt_about); cv_forecast = (CardView) itemView.findViewById(R.id.cv_forecast); } @Override public void onClick(View v) { View cardView = (View)itemView.findViewById(R.id.forecast_cardview_all); if (about.getVisibility()==View.GONE) { about.setVisibility(View.VISIBLE); cardView.setBackgroundResource(R.color.forecast_about_all); //TODO здесь делаю видимым поле для данных после onClick }else if (about.getVisibility()==View.VISIBLE){ about.setVisibility(View.GONE); cardView.setBackgroundResource(R.color.white); } } } }