我在自定义BaseAdapter中的getView方法中有这段代码:
public final View getView(int position, View convertView, ViewGroup parent) {
Log.e("blah","getView "+position);
View itemView = convertView;
ItemController renderer;
ItemType item = getItem(position);
if (itemView == null) {
renderer = createNewRenderer(item);
renderer._setItem(item);
itemView = renderer.createLayout(inflater);
renderer.init();
} else {
renderer = (ItemController) itemView.getTag();
if (renderer.getItem() != null && renderer.getItem() != item) {
renderer.dispose(); // Recycle images and other stuff
dispose(renderer); // I need to keep a mapping between the items in the gridview to the renderers, this will point older item to nothing.
}
// if (!reuseViews)
// itemView = renderer.createLayout(inflater);
renderer._setItem(item);
}
populateController(item, renderer);
renderer.renderImpl();
return itemView;
}
这是渲染3x3 GridView的输出:
getView #0
getView #0
getView #0
getView #1
getView #2
getView #3
getView #4
getView #5
getView #6
getView #7
getView #8
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
我在加载后动态渲染每个ItemRenderer的内容......
注意除第一项外,所有项目的表现都很好。
当我向下滚动时:
getView #9
getView #10
getView #11
getView #12
getView #13
getView #14
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #15
getView #16
getView #17
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #18
getView #19
getView #20
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #21
getView #22
getView #23
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #24
getView #25
getView #26
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #27
getView #28
getView #29
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
getView #0
任何人都知道为什么?