Android ListView save items onClick in adapter
<p>I have a listview which is in a CustomAdapter, I have the ListView clickable, so when users click a row a little checkmark appears next to it. My problem is that if you scroll down the ListView and then come back up the CheckMark disappears or it forgets what item's where clicked. This is the image
<a href="https://i.stack.imgur.com/Usus6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Usus6.png" alt="enter image description here"></a> </p>

<p>As you can see the image correctly appears when an item is clicked but if you scroll down then up again the image is gone. This is what I have in my ListView</p>

<pre><code>  @Override
    public View getView(int position,View convertView,ViewGroup parent) {
        final ViewHolder holder;
     if(convertView==null){
         holder  = new ViewHolder();
         inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         convertView = inflater.from(c).inflate(R.layout.mylists, null);
         // Initialize
         holder.textView=(TextView) convertView.findViewById(R.id.textView);


         binding.list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

             @Override
             public void onItemClick(AdapterView&lt;?&gt; adapterView, View view,int position, long l) {

                 holder.selected_genres = (ImageView) view.findViewById(R.id.selected_genre);
                 holder.selected_genres.setVisibility(View.VISIBLE);
             }

         });


          convertView.setTag(holder);
    }else {
         holder = (ViewHolder) convertView.getTag();
     }
        lists= mylist.toArray(new String[0]);

        holder.text1.setText(lists[position]);

        return convertView;
    }
</code></pre>