title: RecyclerView change image on click
body: <p>I'm making ola like car selecting function. I've an API from which I'm getting car type, selected image link and unselected image link. I'm using recyclerview with text and image view for that. While creating the recyclerview I'm selecting first position and displaying <code>hover-image</code> to show selected. When I select another image it changes to selected image but the previously selected one doesn't changes to unselected image. This means that the for loop is not working. But when I printed the url link for the unselected images the url link shows correct. Then why its not showing in Picasso.  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.MyViewHolder&gt; {
  
      private List&lt;Model&gt; arrayList;
      private Context context;
  
      public MyAdapter(Context context, List&lt;Model&gt; arrayList) {
          this.arrayList = arrayList;
          this.context = context;
      }
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.rowlayout, parent, false);
  
          return new MyViewHolder(itemView);
      }
  
      class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
          TextView txt;
          ImageView image;
          LinearLayout LL_root;
  
          MyViewHolder(View view) {
              super(view);
              txt = (TextView) view.findViewById(R.id.txt);
              image = (ImageView) view.findViewById(R.id.image);
              LL_root = (LinearLayout) view.findViewById(R.id.LL_root);
              LL_root.setOnClickListener(this);
          }
  
          @Override
          public void onClick(View view) {
              switch (view.getId()){
                  case R.id.LL_root:
                      int pos = getAdapterPosition();
                      System.out.println("sammy_onclick_position "+pos);
  
  
  
                      for(int i=0; i&lt;arrayList.size(); i++){
                          if(pos!=i){
                              Picasso.with(context).load(arrayList.get(i).getImage()).into(image);
                              System.out.println("sammy_unselected_image "+arrayList.get(i).getImage());
                          }
                      }
                      Picasso.with(context).load(arrayList.get(pos).getSelectedImage()).into(image);
                      System.out.println("sammy_selected_image "+arrayList.get(pos).getSelectedImage());
                      break;
              }
          }
      }
  
      @Override
      public void onBindViewHolder(MyViewHolder holder, int position) {
          Model model = arrayList.get(position);
          holder.txt.setText(model.getTitle());
          if (!TextUtils.isEmpty(model.getImage())){
              if(position==0)
                  Picasso.with(context).load(model.getSelectedImage()).into(holder.image);
              else
                  Picasso.with(context).load(model.getImage()).into(holder.image);
          }
  
      }
  
      @Override
      public int getItemCount() {
          return arrayList.size();
      }
  }</code></pre>
  </div>
  </div>
  </p>