title: Android Listview row repeating item
body: <p>I have a list where on specific number(position) that i get from shared preferences an imageview should be shown(indicates what song is currently playing) . But i get the position,but that item is showing on other rows as well. The problem is occurring when i scroll the list.</p>
  
  <p>*This is happening when i exit another activity, and on my on resume i to this:</p>
  
  <pre><code>@Override
  protected void onResume() {
      super.onResume();
      if(AlbumDetails.mediaPlayer!=null)
      adapter = new PlaylistAdapter(this, songs);
      list.setAdapter(adapter);
  }
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>public class PlaylistAdapter extends BaseAdapter {
  
      private Activity activity;
      private static LayoutInflater inflater = null;
      private ArrayList&lt;Songs&gt; data;
      private DatabaseHelper db;
      private SharedPreferences prefs;
      int playpos;
  
      public PlaylistAdapter(Activity a, ArrayList&lt;Songs&gt; songs) {
          activity = a;
          data = songs;
          db = new DatabaseHelper(a);
          inflater = (LayoutInflater) activity
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          prefs = activity.getSharedPreferences("com.darkovski.quran",
                  Context.MODE_PRIVATE);
          playpos = prefs.getInt("posPlaying", -1);
      }
  
      public int getCount() {
          return data.size();
      }
  
      public Object getItem(int position) {
          return position;
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      public View getView(final int position, View convertView,
              final ViewGroup parent) {
          View vi = convertView;
          if (convertView == null)
              vi = inflater.inflate(R.layout.song_item, parent, false);
  
          ImageView download = (ImageView) vi
                  .findViewById(R.id.playlist_item_download);
          db.openDB();
          if (db.isDownloaded(data.get(position).getNumber(), data.get(position)
                  .getRecitorName(), data.get(position).getRecitorID()))
              download.setImageResource(R.drawable.download_yes);
          else {
              download.setImageResource(R.drawable.download_no);
              download.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      new DownloadFileFromURL(activity, data.get(position)
                              .getRecitorName(), data.get(position).getTitle(),
                              data.get(position).getLink(), data.get(position)
                                      .getNumber(), data.get(position)
                                      .getRecitorID()).execute();
                      if (!db.isDBOpen())
                          db.openDB();
                      db.addDownloaded(data.get(position).getNumber(),
                              data.get(position).getLink(), 0, data.get(position)
                                      .getRecitorID(), "", data.get(position)
                                      .getTitle());
  
                      Toast.makeText(activity,
                              "Downloading " + data.get(position).getTitle(),
                              Toast.LENGTH_SHORT).show();
  
                  }
              });
          }
          db.closeDB();
  
          TextView number = (TextView) vi.findViewById(R.id.playlist_item_num);
          TextView title = (TextView) vi.findViewById(R.id.playlist_item_reciter);
          title.setText(data.get(position).getTitle());
          number.setText((position + 1) + "");
          ImageView eq = (ImageView) vi.findViewById(R.id.playlist_item_equlizer);
          //this is where i show the item
          if (playpos == position) {
              eq.setVisibility(View.VISIBLE);
          }
  
          return vi;
      }
  }
  </code></pre>
  
  <p>And this is how it looks:</p>
  
  <p><img src="https://i.stack.imgur.com/ZfX28.png" alt="enter image description here"></p>