getView () . As indicated in the specifications, the getView method displays data at the specified position. That way, when you install the adapter and when you scroll through your listView method, getView is called.
The method you copied here is part of the EfficientAdapter to optimize the performance of the ListView and along with the optimization, you used the ViewHolder template.
Copied to specs: with fewer explanations
position : the position of the element in the adapter dataset of the element we want to see.
convertView . Old view for reuse if possible. Note. You must verify that this is using an invalid representation and appropriate type before use. If it is not possible to convert this view to display the correct data, this method can create a new view. Heterogeneous lists can indicate their number of view types, so this view always has the correct type (see GetViewTypeCount () and getItemViewType (int)).
So, in the above method, when you do the following, you reuse the converted one.
if (convertView == null){ .... convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); }
And by doing the following, you avoid searching (findViewById), that’s what’s good in the ViewHolder template
holder.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1);
parent : parent element that will eventually be bound to
Edited
Question: How many times getView is called and how many convertView will be created? Answer: Let's take an example of the Efficeint Adapter from ApiDemos . If 10 lines are displayed on your screen, then
convertView Count : 10 + 1 = 11 (10 Builds what you see on the screen, another one to show the scroll effect). This means that if (convertView == null) {...} statements will only be called 11 times.
getView Count . Initially, the count will be 10, but when you start to increase the scroll counter. getView is called every time to update the data.
Note. This is true only for the getView method mentioned in the question.