I have a very simple activity that extends ListActivity. I override the onListItemClick method by performing some custom operations.
What I saw in the logs is that after calling the list item (which I also override) to get the list created by user views, the methode method is called getView.
Now I would like to know if this behavior is correct or not. If it could be a problem.
The problem is that there are images in my list items that are retrieved from the Internet, and when I click on the list item, calling the adapter calls on the Internet, updating the images in the list and spoiling them for some reason.
Can someone obscure some light?
this is mine getView:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ContentListItemView cv = null;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(this.context);
convertView = (RelativeLayout) inflater.inflate(this.layout, null);
cv = new ContentListItemView(convertView);
} else {
cv = (ContentListItemView) convertView.getTag();
}
Log.d(this.getClass().getSimpleName(), "position: " + position);
cv.init(getItem(position));
convertView.setTag(cv);
return convertView;
}
and this is mine OnListItemClick
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent contentDetailsIntent = new Intent(this, ContentDetailsActivity.class);
contentDetailsIntent.putExtra("com.tamtamy.jatta.content_list_item_selected", position);
contentDetailsIntent.putExtra("com.tamtamy.jatta.datasource", ContentDetailsActivity.CONTENT_LIST);
contentDetailsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(contentDetailsIntent);
}
source
share