问题描述:

My app presents a couple ListViews backed by a database. Each uses a cursor adapter and a provider to interface between the database and UI. In one case I use SimpleCursorAdapter out of the box (With a custom ViewBinder); in the other case I've subclassed SimpleCursorAdapter.

In tracing through my app I find that every time these ListViews load, the cursor adapters are calling their getView() and bindView() methods twice on each item in the list. Why is that happening, and is there any way to avoid it?

网友答案:

If you are setting the width (or height) of a ListView to wrap_content it will cause this issue. Switched it to Fill_Parent or match_parent Setting the width (or height) of a ListView to wrap_content will cause it to measure the first 3 items and base its dimensions off of those. In order to measure those first 3 items, it must call bindView() to populate them. Once it has measured, it will populate fully and call bindView() again on those first 3 and any subsequent.

see the same issue Why does Wrap_Content fire BindView more than once

相关阅读:
Top