0

I am working with a multimedia player. Where song list is shown on listView. so for example if first song is playing the first row should marked as playing and other row should unmarked. Then if user click on third or second or any other row then current row should be unmarked. And clicked row should marked. Here marked and unmarked mean Play and Pause. I do play and pause toogle with same row. But how to change the element of earlier row? Can I store View of earlier row in a View ? or anything else?

Here is the code of setOnClickListener

imageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                ImageView imagEar = (ImageView) viewEar.findViewById(R.id.thumb);

                imagEar.setImageResource(R.drawable.pause);
                imagEar.setTag("pause");

                viewEar = v;

                if(imageView.getTag().toString().equals("play")){
                    imageView.setImageResource(R.drawable.pause);
                    imageView.setTag("pause");
                }else if(imageView.getTag().toString().equals("pause")){
                    imageView.setImageResource(R.drawable.play);
                    imageView.setTag("play");
                }
            }
        });

I already declared View viewEar;

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

Hi check the below url for more understanding on your requirement. Basically you have to take one variable says selectedPosition upon on clicking item you change change the selectedPostion value and by using that u can apply changes on that view and by calling notifySetChanged() which refresh the list.

http://www.devexchanges.info/2015/11/listview-with-checkbox-single-row.html

praveen2034
  • 109
  • 6
  • else u can create a method in adapter which takes selected position or something. by using that u can change value in adapter and then do notify. it will work well. – praveen2034 Aug 10 '18 at 17:35