I have the following code in the method getView of my adapter (which populates a ListView)
public View getView(int position, View parent, ViewGroup root) {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.my_layout, null);
ImageView imageView = view.findViewById(R.id.myImageView);
String address = addresses[position];
MyNetworkLibrary.loadAndSetImage(address, imageView);
return view;
}
The cells of the ListView have an ImageView in which they load a remote image.
The method MyNetworkLibrary.loadAndSetImage download the remote image and, when it has received the response, sets it in my ImageView. The problem is that the method getView is often called more than once for each row of the ListView, than, though I use a cache, since the image is not into the cache my app performs more than one request for each row.
Is there a way for knowing when getView is called for the last time for a row? Or, do you think about a better solution?