In gridview adapter, getView(position == 0) was invoked too many times to measure layout when setImageBitmap() in a loader

后端 未结 4 1463
暖寄归人
暖寄归人 2021-02-05 05:26

I have a GridView for showing some icons.

BEFORE I had read this Displaying Bitmaps Efficiently from Android developer site, I was decoding bitmap from loca

4条回答
  •  太阳男子
    2021-02-05 05:56

    I had the same problem. Grid is always measuring its first child, even if I am in 30 position.
    I just bypass the whole getView code by adding this check in getView top:

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // Patch for multiple getView for position 0
        if(convertView!=null && position==0 && viewGrid.getFirstVisiblePosition()>1) return convertView;
    

    This does not stop getView being called, but at least texts, images and layout changes don' t run.

提交回复
热议问题