Listview multi duplicate action?
<p>i have duplicate action issue in my Listview I've made many research on the internet all failed my issue is when i click on item number 1 its expanded and when i scroll down the pagination append more items and i found item number 10 is also expanded , another example if i toggle item number 2 the both number 2 and number 12 items are toggled together !!</p>

<p>how to fix this duplicate issue ?</p>

<p>this is the listview class</p>

<pre><code>public class Ringtones_Listview extends ArrayAdapter&lt;Object&gt; {

    int resource;
    String response;
    Context context;
    private LayoutInflater mInflater;
    MediaPlayer mp = null;
    ImageView play_clicked;
    View vv = null;
    String lang = Locale.getDefault().getDisplayLanguage();
    ArrayList ob;
    Integer clickedposition; 

    public Ringtones_Listview(Context context, int resource, ArrayList objects) {
        super(context, resource,objects);

        this.context = context;
        this.ob = objects;
        this.resource = resource;
        mInflater = LayoutInflater.from(context);
    }
    public int getCount() {
        return ob.size();
    }

    public JSONObject getItem(JSONObject position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    static class ViewHolder {

        ImageView play ;
        ImageView download ;
        TextView  rtitle;
        TextView  size;
        TextView  downloads;
        TextView  personname;
        TextView  date;
        RatingBar ratingsmall;
        ImageView ratebutton;
        long    tonid;
        TextView  voters;
        LinearLayout more;
    }

    @SuppressWarnings("deprecation")
    public View getView(final int position, View convertView, ViewGroup parent)
    {
        ViewHolder holder;
        //Get the current location object
        JSONObject r = (JSONObject) getItem(position);

        //Inflate the view
       if(convertView == null)
       {

            convertView = mInflater.inflate(R.layout.ringtone_bit, null);
            holder = new ViewHolder();
            convertView.setTag(holder);


            holder.play        = ( ImageView ) convertView.findViewById(R.id.play);
            holder.download    = ( ImageView ) convertView.findViewById(R.id.download);
            holder.ratebutton  = ( ImageView ) convertView.findViewById(R.id.ratebutton);
            holder.rtitle      = (TextView)  convertView.findViewById(R.id.rtitle);
            holder.size        = (TextView)  convertView.findViewById(R.id.size);
            holder.downloads   = (TextView)  convertView.findViewById(R.id.downloads);
            holder.voters      = (TextView)  convertView.findViewById(R.id.voters);
            holder.personname  = (TextView)  convertView.findViewById(R.id.personname);
            holder.date        = (TextView)  convertView.findViewById(R.id.date);
            holder.ratingsmall = (RatingBar) convertView.findViewById(R.id.ratingsmall);
            holder.more = ( LinearLayout ) convertView.findViewById(R.id.more);

      }
      else
       {
            holder = (ViewHolder) convertView.getTag();
       }

           //hide More information
           holder.more.setVisibility(View.GONE); 

          try {
            Date date_g = new Date(r.getLong("timestamp") * 1000);
            holder.date.setText(date_g.toLocaleString());
            } catch (JSONException e2) {}

           //set person name
            try {
                String client_name = ( r.getString("personname").equals( "null" ) == true ) ? "ghost" : r.getString("personname");
                holder.personname.setText(client_name);
            } catch (JSONException e2) {}

            //set total votars and vote avarage
            try {
                float z = (float) r.getInt("rate");
                holder.voters.setText(" ( "+ r.getLong("voters") +" ) / " + z);
            } catch (JSONException e2) {}            
            //set rating bar
            try {
                float z = (float) r.getInt("rate");
                holder.ratingsmall.setRating(z);
            } catch (JSONException e2) {}           
            //set ringtone Name as defualt device language
            try {
                String name = ( lang.equals( "English" ) == true ) ?  r.getString("en_name") : r.getString("ar_name");
                holder.rtitle.setText(name);
            } catch (JSONException e2) {}

            //ringtone file size
            try {
                holder.size.setText(r.getString("size"));
            } catch (JSONException e2) {}

            //set downloads
            try {
                holder.downloads.setText(String.valueOf( r.getLong("downloads") ));
            } catch (JSONException e2) {}

            //set ringtone ID toneid
            try {
                  holder.tonid = r.getLong("toneid");
                  holder.download.setTag(r.getLong("toneid"));
                  holder.ratebutton.setTag(r.getLong("toneid"));
                  holder.play.setId((int) r.getLong("toneid"));
                  convertView.setId((int) r.getLong("toneid"));

               } catch (JSONException e1) {}

            //set download stram url to play icon
            try {
                holder.play.setTag(r.getString("stream_url"));
            } catch (JSONException e) {}

            //add play listener test Ringtone before download it
            holder.play.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View v) {

                    clickedposition=position;
                    boolean playit = false;

                     v.setMinimumHeight(200);

                     //stop Media player dont play any thing
                     if ( mp != null )
                     {
                         mp.stop();
                         mp.release();
                         mp = null;
                     }

                     //check for last clicked item
                     if ( vv != null )
                     {
                         //set last played item to play icon
                         vv.setBackgroundResource(R.drawable.play); 

                         //check if last played is not smae clicked item
                         if( v.getTag().toString().equals( vv.getTag().toString() ) == false )
                         {
                             playit = true; 
                         }else
                        //its same item dont play stop here  
                         {
                             vv     = null;
                         }
                     }else
                    //nothing played yet play it
                     {
                         playit = true; 
                     }


                     if ( playit )
                     {

                         vv = v;

                         v.setBackgroundResource(R.drawable.preparing_player); 


                         AnimationDrawable frameAnimation = (AnimationDrawable) v.getBackground();
                         frameAnimation.start();


                         String stramUrl = String.valueOf(v.getTag());


                         try {

                             mp = new MediaPlayer();
                             mp.setAudioStreamType(AudioManager.STREAM_MUSIC);   
                             mp.setDataSource(stramUrl);
                             mp.prepareAsync();


                         } catch (Exception e) {}


                         //preparing straming
                         mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

                            @Override
                            public void onPrepared(MediaPlayer mps) {

                                 v.setBackgroundResource(R.drawable.played); 
                                 mps.start(); 
                            }
                        });

                        mp.setOnCompletionListener( new MediaPlayer.OnCompletionListener() {

                            @Override
                            public void onCompletion(MediaPlayer mp) {
                                 v.setBackgroundResource(R.drawable.play); 
                            }
                        });

                     }          




                }
            });




        return convertView;
    }

}
</code></pre>
