Prevent the adapter from recycling views on scroll ( Edit do not ever do this.)

后端 未结 4 1186
走了就别回头了
走了就别回头了 2020-12-16 04:35

I have a custom base adapter that will take in an arraylist of data. From here it will fill out a grid view with custom buttons. It does so perfectly and fills up the gridvi

4条回答
  •  星月不相逢
    2020-12-16 05:06

    Prevent the adapter from recycling views on scroll

    Just don't use the convertView param passed to getView() and always return a freshly generated View.

    However, this is a bad solution in terms of performance. Instead, your goal should not be to prevent recycling but to recycle correcltly: Your getView() should reset the convertView to it's pristine state.

    So, if there's a change that some of your Button's properties are changed from their non-default values, reset them back to defaults in getView().

提交回复
热议问题