ListView is not showing correct values after scrolling

好久不见. 提交于 2019-12-03 04:56:07

ListViews recycle views, which means at first a base set of list entries is inflated from XML. When you scroll down now, one list entry gets hidden at the top, and a new one gets shown at the bottom. At this moment getView() is called with a non-null argument convertView, because an already inflated view is reused.

In your case that means that the whole layout inflation/setup is skipped (the if (v == null) tree). Which is fine, basically all you have to do is update the timestamp in the second if section (o != null).

It should contain something similar to this, like you did with the textviews too:

CustomAnalogClock customAC = (CustomAnalogClock) v.findViewById(R.id.yourclockid);
customAC.setTime(o.getOrderTime());

This means that you have to assign an ID (by using setId()) to your view while adding it to the layout, and also have to have a setTime() method ready.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!