Max Usanin
Max Usanin

Reputation: 2499

How does ArrayAdapter.getView() work?

I am extending ArrayAdapter<UrlItem> class and have overridden the following method:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
}

I observed that, this method gets called several times. I want to ask, how do you know how many times this gethod gets called to return the View? I want to know how getView() works?

Upvotes: 0

Views: 529

Answers (2)

user370305
user370305

Reputation: 109257

There is absolutely no guarantee on the order in which getView() will be called nor how many times.

Look at this SO Question custom listview adapter getView method being called multiple times, and in no coherent order and a nice tutorial http://android.amberfog.com/?p=296 .

Upvotes: 1

Android Dev
Android Dev

Reputation: 198

No. of getview calling method is depend on no. of objects or size of arraylist you passed in adapter. suppose you want to display 5 items in listview of gridview then this method is called 5 times.

Upvotes: 1

Related Questions