Well, it is possible.
Override the methods getView and add of the ArrayAdapter
What i did for example as testcase:
public class custom_row extends ArrayAdapter<String> {
String newItem = "";
Boolean doRefresh = true;
public custom_row(Context context, int resource, ArrayList<String> objects) {
super(context, resource, objects);
}
public custom_row(Context context, int resource, String[] objects) {
super(context, resource, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
String itemValue = getItem(position);
if (doRefresh == false && itemValue != newItem) {
return convertView;
}
LayoutInflater inflater = LayoutInflater.from(getContext());
View customView = inflater.inflate(R.layout.customr_row, parent, false);
ImageView myImageView = (ImageView) customView.findViewById(R.id.imageView);
String url = "https://urltoimage/image.jpg";
(new DownloadImageTask(myImageView)).execute(url);
TextView myTextView = (TextView) customView.findViewById(R.id.myCustomText);
myTextView.setText(itemValue);
return customView;
}
public void addNewItemToList(String item) {
this.newItem = item;
this.doRefresh = false;
add(item);
}
private class DownloadImageTask extends AsyncTask<String, Integer, Bitmap>{
private ImageView mImageView;
public DownloadImageTask(ImageView imageView) {
this.mImageView = imageView;
}
@Override
protected Bitmap doInBackground(String... params) {
URL url = null;
Bitmap bmp = null;
try {
url = new URL(params[0]);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
InputStream stream = url.openStream();
bmp = BitmapFactory.decodeStream(stream);
} catch (IOException e) {
e.printStackTrace();
}
return bmp;
}
@Override
protected void onPostExecute(Bitmap bmp) {
this.mImageView.setImageBitmap(bmp);
}
}
}
The first time it loads all the items and the images are loaded dynamically by the Async thread. The following part of the code in method getView prevents the list from refreshing it completely, so preventing the blinking of the images:
String itemValue = getItem(position);
if (doRefresh == false && itemValue != newItem) {
return convertView;
}
The ArrayAdapter will go through the list again when a new item is added to the list. Just check whether the item at the current position is the newly added item. If not then return the convertView which is the old view or else load the item and return the custom view.