原因:
因为getView()被调用的次数取决于当前屏幕能显示item的数量,显示一个item就调用一次.当ListView的layout_height属性为wrap_content时,有可能会导致无法计算ListView的高度,相应的显示item的数量也无法计算,从而使得getView()被多次调用.
解决方案:
方案一:
在ListView外面套一层RelativeLayout,将ListView的高度设置为fill_parent.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android......
阅读全文