0%

Android开发:ListView的adapter里getView方法重复调用的问题解决

如果按网上大部分文章说的,item的高度固定,listview的高度match_parent,getView仍然重复调用,看看ListView的parent layout是不是RelativeLayout. 如果是RelativeLayout,而ListView的layout_width不是match_parent,即使写了xxdp,getView也会重复调.原因在于,在RelativeLayout中,控件真正的宽度同时受限于他相对的控件。所以解决方法是,把RelativeLayout换成LinearLayout或者宽度设为match_parent