2017-02-15 5 views
0

Я действительно мог бы здесь помочь. получил несколько ДНЕЙ, пытаясь понять, что неправильно, и не может найти его. Вот как это делаетсяRecyclerview контролирует дублирование

каждый раз, когда я делаю data.remove (position) notifyitemremove (position), он деинкодирует и удаляет элементы вправо, но элементы удаляются до тех пор, пока список не попадет в первый элемент, а затем произойдет сбой приложения.

Затем я использую notifyitemrangechange (position, data.size()), и идентификатор сохраняет позицию правильно. НО что-то происходит с представлениями, и они начинают получать данные мусора из удаленных просмотров ... проблема сводит меня с ума, плохо прикреплять изображения и адаптер, так как каждый из них происходит там.

Важно заметить, что если я удаляю виды справа налево, все работает просто идеально. переработчик прокручивается горизонтально.

fresh start after deletion

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder{ 

     private ArrayList<Comanda> list_comandas; 
     private LayoutInflater inflater; 


      inflater = LayoutInflater.from(context); 
      this.list_comandas = list_comandas; 
     } 

     @Override 
     public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) 
     { 
     View view = inflater.inflate(R.layout.row, parent, false); 
     MyViewHolder holder = new MyViewHolder(view); 
     return holder; 
     } 

     @Override 
     public int getItemCount() 
     { 
      return list_comandas.size(); 
     } 

    @Override 
    public void onBindViewHolder(MyViewHolder holder, int position) { 

     Comanda comanda = list_comandas.get(position); 

      holder.setData(comanda, position); 

     // mostrarMensaje("agregado:" + position); 



    private void mostrarMensaje(String mensaje) 
    { 
     Toast.makeText(inflater.getContext(), mensaje, Toast.LENGTH_SHORT).show(); 
    } 



    class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ 

     //definicioin de variables 

     TextView txt_comanda; 
     TextView txt_mesa; 
     TextView tid; 
     TextView torden; 
     TextView te; 

     Button btn_cerrar; 
     Button be; 
     LinearLayout le; 
     private LinearLayout lyocomanda; 

     private int position; 
     private int anchomanda = Math.round(inflater.getContext().getResources().getDimension(R.dimen.parents_size)); 

     public MyViewHolder(View itemView) { 
      super(itemView); 

      //inicializacion de controles 

      lyocomanda = (LinearLayout) itemView.findViewById(R.id.lyocomanda); 

      txt_comanda = (TextView) itemView.findViewById(R.id.txt_comanda); 

      txt_mesa = (TextView) itemView.findViewById(R.id.txt_mesa); 

      tid = (TextView) itemView.findViewById(R.id.tid); 

      torden = (TextView) itemView.findViewById(R.id.torden); 

      btn_cerrar = (Button) itemView.findViewWithTag("primal"); 
      btn_cerrar.setOnClickListener(MyViewHolder.this); 

     } 

     void setData(Comanda comanda, int position) { 

      //setear la data 

      this.position = position; 

      String cadena= comanda.getOrden(); 

      Integer tope = cadena.length(); 

      Boolean tijera_categoria = false; 
      Boolean tijera_articulo = true; 
      Boolean tijera_contorno = true; 
      Boolean tijera_cambio = true; 
      boolean creador=false; 

      Integer indisup; 
      Integer indiin = 0; 
      char apuntador; 
      String Buscado = ""; 
      String Buscado_contorno = ""; 
      String Buscado_categoria = ""; 
      Integer id = -1; 

      String tag=""; 

      this.txt_comanda.setText(this.position+""); 

      this.txt_mesa.setText(comanda.getMesa()); 

      this.tid.setText(comanda.get_id()); 

      this.torden.setText(comanda.getOrden()); 

      this.btn_cerrar.setOnClickListener(MyViewHolder.this); 


      for (int i = 0; i < tope ; i++) { 


       apuntador =cadena.charAt(i); 

       if (Buscado.equals("Bebidas")) 
       { 
        cadena=""; 
        break; 
       } 
       else 
       { 
        if (apuntador == '$') 
        { 
         cadena=""; 
         break; 
        } 
        else 
        { 
         //EJECUCION PRINCIPAL 

         if (apuntador == '#' && !tijera_categoria) { 
          if (i == 0) { 
           indiin = i + 1; 
          } 
         } 

         if (apuntador == '!' && !tijera_categoria) { 
          tijera_categoria = true; 
          tijera_articulo = false; 
          indisup = i; 

          id =id+1; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          Buscado_categoria = Buscado; 

          tag= position + ""+id; 
          this.be = new Button(inflater.getContext()); 
          creador= true; 
          this.be.setTag(tag); 
          // this.be.setId(position); 
          this.be.setOnClickListener(MyViewHolder.this); 
         } 

         if (apuntador == '%' && !tijera_articulo) { 
          indisup = i; 
          tijera_articulo = true; 
          tijera_contorno = false; 

          Buscado = cadena.substring(indiin, indisup); 

          indiin = indisup + 1; 

          this.be.setTextSize((inflater.getContext().getResources().getDimension(R.dimen.txt_size))/2); 
          if (Buscado_categoria.equals("Fondos")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.fondos, null)); 
          } 
          if (Buscado_categoria.equals("Entradas")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.entradas, null)); 
          } 
          if (Buscado_categoria.equals("Postres")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.postres, null)); 
          } 
          be.setText(Buscado); 
          be.setLayoutParams(new LinearLayout.LayoutParams(this.anchomanda, LinearLayout.LayoutParams.WRAP_CONTENT)); 
          this.lyocomanda.addView(be); 
         } 

         if (apuntador == '*' && !tijera_contorno) { 
          indisup = i; 
          tijera_cambio = false; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          if (!Buscado.equals("")) { 
           Buscado_contorno = Buscado; 
           this.te = new TextView(inflater.getContext()); 
           this.te.setText(Buscado); 
           this.te.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 
           this.te.setTextSize((inflater.getContext().getResources().getDimension(R.dimen.txt_size))/2); 

           if (creador){ 
            this.le = new LinearLayout((inflater.getContext())); 
            creador=false; 
           } 


           this.le.addView(this.te); 

          } 

         } 

         if (apuntador == '#' && !tijera_cambio) { 
          indisup = i; 
          tijera_contorno = true; 
          tijera_cambio = true; 
          tijera_categoria = false; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          if (!Buscado_contorno.equals("")) { 
           this.le.setLayoutParams(new LinearLayout.LayoutParams(anchomanda, ViewGroup.LayoutParams.WRAP_CONTENT)); 
           this.le.setOrientation(LinearLayout.VERTICAL); 
           this.le.setBackground(inflater.getContext().getDrawable(customborder)); 
           this.lyocomanda.addView(this.le); 
           //cadena =""; 
          } 

         } 


        }//FIN DE LA EJECUCION PRINCIPAL 
       }//DEL INICIO DE EJECUCION PRINCIPAL 

      }// DEL FOR 

     } 

     @Override 
     public void onClick(View v){ 
      if (v.getTag().equals("primal")){ 
       mostrarMensaje("borrado" + position); 
       removeItem(position); 
      }else{ 
       mostrarMensaje("BOTON NO CONFIGURADO:" + v.getTag().toString()); 
      } 
     } 

     private void removeItem(int position) { 
      list_comandas.remove(position); 
      notifyItemRemoved(position); 
      //notifyItemRangeChanged(position,list_comandas.size()); 
      //notifyItemRangeChanged(position, getItemCount() - position); 
      // notifyDataSetChanged(); 
     } 

     private void addItem(int position, Comanda comanda) { 
      list_comandas.add(position, comanda); 
      notifyItemInserted(position); 
      notifyItemRangeChanged(position,list_comandas.size()); 
      //notifyDataSetChanged(); 
     } 
    } 
    } 

основной адаптер утилизатор строка:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:focusableInTouchMode="true" 
    android:layout_height="wrap_content"> 

<!-- Recycler View Item Row --> 
    <RelativeLayout 
     android:id="@+id/comanda" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:focusableInTouchMode="true" 
     android:background="@drawable/customborder"> 

     <RelativeLayout 
      android:id="@+id/lyocabeza" 
      android:layout_width="@dimen/parents_size" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/lbl_comanda" 
       android:layout_alignParentTop="true" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="@dimen/txt_size" 
       android:text="Comanda:"/> 

      <TextView 
       android:id="@+id/txt_comanda" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="@dimen/txt_size" 
       android:layout_toRightOf="@id/lbl_comanda" 
       android:hint="00000"/> 

      <TextView 
       android:id="@+id/txt_mesa" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:textSize="@dimen/txt_size" 
       android:hint="9999"/> 

      <TextView 
       android:id="@+id/lbl_mesa" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="@dimen/txt_size" 
       android:text="Mesa:" 
       android:layout_toLeftOf="@+id/txt_mesa"/> 

      <Button 
       android:id="@+id/btn_cerrar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/lbl_comanda" 
       android:text="Cerrar Comanda" 
       android:tag="primal"/> 

      <TextView 
       android:id="@+id/tid" 
       android:layout_width="1dp" 
       android:layout_height="1dp" 
       android:visibility="invisible"/> 

      <TextView 
       android:id="@+id/torden" 
       android:layout_width="1dp" 
       android:layout_height="1dp" 
       android:visibility="invisible"/> 


     </RelativeLayout> 


     <ScrollView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/lyocabeza"> 
      <LinearLayout 
       android:id="@+id/lyocomanda" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

       <!-- AUTO GENERATED CONTROLS --> 



      </LinearLayout> 

     </ScrollView> 



    </RelativeLayout> 


</LinearLayout> 

как вы можете видеть мои данные динамична, и мне нужно больше или меньше элементов управления в зависимости от данных, так row CANT быть статичным, ну, то есть это сейчас, заблаговременно за любую помощь

ответ

1

Основная проблема с вашим подходом заключается в использовании position внутри MyViewHolder. Следует отметить это на onBindViewHolder:

RecyclerView не будет вызывать этот метод снова, если изменяется положение элементов в наборе данных, если сам элемент является аннулированных или новое положение не может быть определена. По этой причине вы должны только использовать параметр position при получении соответствующего элемента данных внутри этого метода и не должны копировать его. Если вам понадобится позиция элемента позже (например, в прослушивателе кликов), используйте {@link ViewHolder # getAdapterPosition()}, который будет иметь обновленную позицию адаптера.

Таким образом, после того, как вы удалите элемент, позиция других будет затронута и может закончиться неправильным положением при запуске события удаления, помните, что виды переработаны.

Вы должны обратиться к позиции текущего элемента с помощью holder.getAdapterPosition().

Попробуйте что-то вроде этого:

обработки onCLickListener за пределами ViewHolder

MyViewHolder

class MyViewHolder extends RecyclerView.ViewHolder { 

     //definicioin de variables 

     TextView txt_comanda; 
     TextView txt_mesa; 
     TextView tid; 
     TextView torden; 
     TextView te; 

     Button btn_cerrar; 
     Button be; 
     LinearLayout le; 
     private LinearLayout lyocomanda; 

     private int anchomanda = Math.round(inflater.getContext().getResources().getDimension(R.dimen.parents_size)); 

     public MyViewHolder(View itemView) { 
      super(itemView); 

      //inicializacion de controles 

      lyocomanda = (LinearLayout) itemView.findViewById(R.id.lyocomanda); 

      txt_comanda = (TextView) itemView.findViewById(R.id.txt_comanda); 

      txt_mesa = (TextView) itemView.findViewById(R.id.txt_mesa); 

      tid = (TextView) itemView.findViewById(R.id.tid); 

      torden = (TextView) itemView.findViewById(R.id.torden); 

      btn_cerrar = (Button) itemView.findViewWithTag("primal"); 

     } 

     void setData(Comanda comanda) { 

      //setear la data 

      String cadena= comanda.getOrden(); 

      Integer tope = cadena.length(); 

      Boolean tijera_categoria = false; 
      Boolean tijera_articulo = true; 
      Boolean tijera_contorno = true; 
      Boolean tijera_cambio = true; 
      boolean creador=false; 

      Integer indisup; 
      Integer indiin = 0; 
      char apuntador; 
      String Buscado = ""; 
      String Buscado_contorno = ""; 
      String Buscado_categoria = ""; 
      Integer id = -1; 

      String tag=""; 

      this.txt_comanda.setText(this.position+""); 

      this.txt_mesa.setText(comanda.getMesa()); 

      this.tid.setText(comanda.get_id()); 

      this.torden.setText(comanda.getOrden()); 

      for (int i = 0; i < tope ; i++) { 


       apuntador =cadena.charAt(i); 

       if (Buscado.equals("Bebidas")) 
       { 
        cadena=""; 
        break; 
       } 
       else 
       { 
        if (apuntador == '$') 
        { 
         cadena=""; 
         break; 
        } 
        else 
        { 
         //EJECUCION PRINCIPAL 

         if (apuntador == '#' && !tijera_categoria) { 
          if (i == 0) { 
           indiin = i + 1; 
          } 
         } 

         if (apuntador == '!' && !tijera_categoria) { 
          tijera_categoria = true; 
          tijera_articulo = false; 
          indisup = i; 

          id =id+1; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          Buscado_categoria = Buscado; 

          tag= position + ""+id; 
          this.be = new Button(inflater.getContext()); 
          creador= true; 
          this.be.setTag(tag); 
          // this.be.setId(position); 
          this.be.setOnClickListener(MyViewHolder.this); 
         } 

         if (apuntador == '%' && !tijera_articulo) { 
          indisup = i; 
          tijera_articulo = true; 
          tijera_contorno = false; 

          Buscado = cadena.substring(indiin, indisup); 

          indiin = indisup + 1; 

          this.be.setTextSize((inflater.getContext().getResources().getDimension(R.dimen.txt_size))/2); 
          if (Buscado_categoria.equals("Fondos")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.fondos, null)); 
          } 
          if (Buscado_categoria.equals("Entradas")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.entradas, null)); 
          } 
          if (Buscado_categoria.equals("Postres")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.postres, null)); 
          } 
          be.setText(Buscado); 
          be.setLayoutParams(new LinearLayout.LayoutParams(this.anchomanda, LinearLayout.LayoutParams.WRAP_CONTENT)); 
          this.lyocomanda.addView(be); 
         } 

         if (apuntador == '*' && !tijera_contorno) { 
          indisup = i; 
          tijera_cambio = false; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          if (!Buscado.equals("")) { 
           Buscado_contorno = Buscado; 
           this.te = new TextView(inflater.getContext()); 
           this.te.setText(Buscado); 
           this.te.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 
           this.te.setTextSize((inflater.getContext().getResources().getDimension(R.dimen.txt_size))/2); 

           if (creador){ 
            this.le = new LinearLayout((inflater.getContext())); 
            creador=false; 
           } 


           this.le.addView(this.te); 

          } 

         } 

         if (apuntador == '#' && !tijera_cambio) { 
          indisup = i; 
          tijera_contorno = true; 
          tijera_cambio = true; 
          tijera_categoria = false; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          if (!Buscado_contorno.equals("")) { 
           this.le.setLayoutParams(new LinearLayout.LayoutParams(anchomanda, ViewGroup.LayoutParams.WRAP_CONTENT)); 
           this.le.setOrientation(LinearLayout.VERTICAL); 
           this.le.setBackground(inflater.getContext().getDrawable(customborder)); 
           this.lyocomanda.addView(this.le); 
           //cadena =""; 
          } 

         } 


        }//FIN DE LA EJECUCION PRINCIPAL 
       }//DEL INICIO DE EJECUCION PRINCIPAL 

      }// DEL FOR 

     } 

MyAdapter

... 

@Override 
public void onBindViewHolder(MyViewHolder holder, int position) { 

    Comanda comanda = list_comandas.get(position); 

    holder.setData(comanda); 

    // set onCLickListener 
    holder.btn_cerrar.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      removeItem(holder.getAdapterPosition()); 
     } 
    }); 

    // mostrarMensaje("agregado:" + position); 

} 

... 

Или вы можете также обрабатывать onCLickListener внутри MyViewHolder ViewHolder

class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ 

     //definicioin de variables 

     TextView txt_comanda; 
     TextView txt_mesa; 
     TextView tid; 
     TextView torden; 
     TextView te; 

     Button btn_cerrar; 
     Button be; 
     LinearLayout le; 
     private LinearLayout lyocomanda; 

     private int anchomanda = Math.round(inflater.getContext().getResources().getDimension(R.dimen.parents_size)); 

     public MyViewHolder(View itemView) { 
      super(itemView); 

      //inicializacion de controles 

      lyocomanda = (LinearLayout) itemView.findViewById(R.id.lyocomanda); 

      txt_comanda = (TextView) itemView.findViewById(R.id.txt_comanda); 

      txt_mesa = (TextView) itemView.findViewById(R.id.txt_mesa); 

      tid = (TextView) itemView.findViewById(R.id.tid); 

      torden = (TextView) itemView.findViewById(R.id.torden); 

      btn_cerrar = (Button) itemView.findViewWithTag("primal"); 
      btn_cerrar.setOnClickListener(MyViewHolder.this); 

     } 

     void setData(Comanda comanda) { 

      //setear la data 

      String cadena= comanda.getOrden(); 

      Integer tope = cadena.length(); 

      Boolean tijera_categoria = false; 
      Boolean tijera_articulo = true; 
      Boolean tijera_contorno = true; 
      Boolean tijera_cambio = true; 
      boolean creador=false; 

      Integer indisup; 
      Integer indiin = 0; 
      char apuntador; 
      String Buscado = ""; 
      String Buscado_contorno = ""; 
      String Buscado_categoria = ""; 
      Integer id = -1; 

      String tag=""; 

      this.txt_comanda.setText(this.position+""); 

      this.txt_mesa.setText(comanda.getMesa()); 

      this.tid.setText(comanda.get_id()); 

      this.torden.setText(comanda.getOrden()); 

      for (int i = 0; i < tope ; i++) { 


       apuntador =cadena.charAt(i); 

       if (Buscado.equals("Bebidas")) 
       { 
        cadena=""; 
        break; 
       } 
       else 
       { 
        if (apuntador == '$') 
        { 
         cadena=""; 
         break; 
        } 
        else 
        { 
         //EJECUCION PRINCIPAL 

         if (apuntador == '#' && !tijera_categoria) { 
          if (i == 0) { 
           indiin = i + 1; 
          } 
         } 

         if (apuntador == '!' && !tijera_categoria) { 
          tijera_categoria = true; 
          tijera_articulo = false; 
          indisup = i; 

          id =id+1; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          Buscado_categoria = Buscado; 

          tag= position + ""+id; 
          this.be = new Button(inflater.getContext()); 
          creador= true; 
          this.be.setTag(tag); 
          // this.be.setId(position); 
          this.be.setOnClickListener(MyViewHolder.this); 
         } 

         if (apuntador == '%' && !tijera_articulo) { 
          indisup = i; 
          tijera_articulo = true; 
          tijera_contorno = false; 

          Buscado = cadena.substring(indiin, indisup); 

          indiin = indisup + 1; 

          this.be.setTextSize((inflater.getContext().getResources().getDimension(R.dimen.txt_size))/2); 
          if (Buscado_categoria.equals("Fondos")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.fondos, null)); 
          } 
          if (Buscado_categoria.equals("Entradas")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.entradas, null)); 
          } 
          if (Buscado_categoria.equals("Postres")) { 
           this.be.setBackgroundTintList(inflater.getContext().getResources().getColorStateList(R.color.postres, null)); 
          } 
          be.setText(Buscado); 
          be.setLayoutParams(new LinearLayout.LayoutParams(this.anchomanda, LinearLayout.LayoutParams.WRAP_CONTENT)); 
          this.lyocomanda.addView(be); 
         } 

         if (apuntador == '*' && !tijera_contorno) { 
          indisup = i; 
          tijera_cambio = false; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          if (!Buscado.equals("")) { 
           Buscado_contorno = Buscado; 
           this.te = new TextView(inflater.getContext()); 
           this.te.setText(Buscado); 
           this.te.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 
           this.te.setTextSize((inflater.getContext().getResources().getDimension(R.dimen.txt_size))/2); 

           if (creador){ 
            this.le = new LinearLayout((inflater.getContext())); 
            creador=false; 
           } 


           this.le.addView(this.te); 

          } 

         } 

         if (apuntador == '#' && !tijera_cambio) { 
          indisup = i; 
          tijera_contorno = true; 
          tijera_cambio = true; 
          tijera_categoria = false; 

          Buscado = cadena.substring(indiin, indisup); 
          indiin = indisup + 1; 

          if (!Buscado_contorno.equals("")) { 
           this.le.setLayoutParams(new LinearLayout.LayoutParams(anchomanda, ViewGroup.LayoutParams.WRAP_CONTENT)); 
           this.le.setOrientation(LinearLayout.VERTICAL); 
           this.le.setBackground(inflater.getContext().getDrawable(customborder)); 
           this.lyocomanda.addView(this.le); 
           //cadena =""; 
          } 

         } 


        }//FIN DE LA EJECUCION PRINCIPAL 
       }//DEL INICIO DE EJECUCION PRINCIPAL 

      }// DEL FOR 

     } 

    @Override 
    public void onClick(View v){ 
     int position = getAdapterPosition(); 
     if (v.getTag().equals("primal")){ 
      mostrarMensaje("borrado" + position); 
      removeItem(position); 
     }else{ 
      mostrarMensaje("BOTON NO CONFIGURADO:" + v.getTag().toString()); 
     } 
    } 
} 
+0

работал как Шарм в первой попытке лол ... Спасибо –

+1

это ничего плохого в обращении 'onCLickListener' indside владелец представления, на самом деле владелец обзора должен использоваться для этого, так как в вашем решении вы создаете новый 'View.OnClickListener' каждый раз, когда вызывается' onBindViewHolder', все, что вам нужно, это использовать метод ViewHolder # get * Position' – pskink

+0

@pskink, вы правы, я отредактировал свой ответ, чтобы указать только на факт использования 'ViewHolder # getAdapterPosi ton() 'в любом случае. – leobelizquierdo