I have a list that has an image, title, options, and a play / pause button. When I press the play button on a line and then press the play button on another line, the background of both buttons remains paused. So I want that when I press the play button on a line and then press the play button on another line, the background of the first button must change to play, and the background of the second should remain paused. thanks in advance

Here is the code
Public class MyAdapter extends BaseAdapter {
int itemnum; Boolean playing = false; Context context; int layoutResourceId; // RingTone data[] = null; private LayoutInflater mInflater; String[] Title; int[] Img; ListView listview; public MyAdapter(Context context, int layoutResourceId, String[] Title,int[] Img, int[] Tone, ListView listview) { mInflater = LayoutInflater.from(context); this.layoutResourceId = layoutResourceId; this.context = context; this.Title=Title; this.Img=Img; ListActivity.Tone=Tone; this.listview=listview; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; RingToneHolder holder = null; if (convertView == null) { convertView = mInflater.inflate(R.layout.listrow, null); } holder = new RingToneHolder(); // RingTone aa = data[position]; holder.imgIcon = (ImageView)convertView.findViewById(R.id.list_image); holder.txtTitle = (TextView)convertView.findViewById(R.id.title); holder.playbtn = (Button)convertView.findViewById(R.id.playbtn); holder.btn_alert_dialog = (Button)convertView.findViewById(R.id.alert_dialog_btn); holder.pausebtn = (Button)convertView.findViewById(R.id.pausebtn); holder.txtTitle.setText(Title[position]); // holder.txtTitle.setText(aa.title); holder.imgIcon.setImageResource(Img[position]); //holder.playbtn.setInputType(aa.btn);S holder.playbtn.setTag(position); holder.btn_alert_dialog.setTag(position); holder.playbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if(mp == null){ listview.invalidateViews(); mp = MediaPlayer.create(context,Tone[Integer.parseInt(arg0.getTag().toString())]); mp.start(); playing = true; itemnum = Integer.parseInt(arg0.getTag().toString()); //Toast.makeText(context, "ist playing", Toast.LENGTH_LONG).show(); arg0.setBackgroundResource(R.drawable.pause); } else { if(mp.isPlaying() && itemnum == Integer.parseInt(arg0.getTag().toString())){ listview.invalidateViews(); mp.pause(); playing = false; //Toast.makeText(context, " paused", Toast.LENGTH_LONG).show(); arg0.setBackgroundResource(R.drawable.play_btn); } else{ if(playing == false && itemnum == Integer.parseInt(arg0.getTag().toString())){ listview.invalidateViews(); mp.start(); playing = true; arg0.setBackgroundResource(R.drawable.pause); } else { //.invalidate(); listview.invalidateViews(); mp.stop(); mp.release(); mp = MediaPlayer.create(context,Tone[Integer.parseInt(arg0.getTag().toString())]); mp.start(); playing = true; itemnum = Integer.parseInt(arg0.getTag().toString()); //Toast.makeText(context, "playing", Toast.LENGTH_LONG).show(); arg0.setBackgroundResource(R.drawable.pause); } } } } });
source share