In list_item.xml file I have a ImageView and one TextView. The code of ImageView is given as
<ImageView
android:id="@+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/play"/>
In main activity (main_activity.java is connected with activity_main.xml, which have one ListView), the music is playing well when user click on music (onItemClick) from list set with setAdapter. Now I want to change the image of this ImageView, when music start to play, when . So I inserted the code as given below:
View inflatedView = getLayoutInflater().inflate(R.layout.list_item, null);
ImageView imgchange = (ImageView)inflatedView.findViewById(R.id.play);
imgchange.setImageResource(R.drawable.pause);
But it is not working. I also tried
android:src="@drawable/imagename"
I also tried
imgchange.setBackgroundResource(R.drawable.pause);
Looking for valuable advise as how can I do it or where is the mistake?