android - getView in BaseAdapter calling behaviour on fling -
say have listview of 20 elements displaying 8 elements @ time screen.
i have noticed getview called many more times when perform fling operation on listview when scroll list (in both cases scrolling/flinging top bottom). question why flinging call getview more times normal scrolling?
i understand there ways make getview efficient understand why getview called more fling operation.
the behavior of getview()
method such called many times views changed in screen. whenever scrolling of listview recycle old records , inflate new records calling getview()
method. view recreated each , everytime scroll list , show new records when scrolling stops.
the adapters built reuse views, when view scrolled no longer visible, can used 1 of new views appearing. reused view convertview. if null means there no recycled view , have create new one, otherwise should use avoid creating new.
convertview
recycling. let's have listview can display 10 item @ time, , displaying item 1 -> item 10. when scroll down 1 item, item 1 out of screen, , item 11 displayed. generate view item 11, getview()
method call, , convertview
here view of item 1 (which not neccessary anymore).
so whenever fling @ time scrolling gets more faster adapter calling getview()
method fast many records comes screen. thats why showing different number of counts of getview()
method.
so instead create new view
object item 11 (which costly), why not re-use convertview
? check convertview
null or not, if null create new view, else re-use convertview
.
Comments
Post a Comment