Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6322519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:20:51+00:00 2026-05-24T16:20:51+00:00

I went through tutorials and searched, but still I can’t understand how the, getView(int

  • 0

I went through tutorials and searched, but still I can’t understand how the,

getView(int position, View convertView, ViewGroup arg2)

method works when extends BaseAdapter to create a custom listView in my android application. Therefore I cant Edit the Custom list view exactly I want.

I need to know when this method invokes and the meanings of the parameters.

If someone can explain the following method its great. Thanks

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

    ViewHolder holder;
    LayoutInflater inflater =  context.getLayoutInflater();

    if (convertView == null)
    {
        convertView = inflater.inflate(R.layout.listitem_row, null);                     
        holder = new ViewHolder();
        holder.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1);
        holder.txtViewDescription = (TextView) convertView.findViewById(R.id.textView2);

        convertView.setTag(holder);
    }
    else
    {
        holder = (ViewHolder) convertView.getTag();                                        
    }

    holder.txtViewTitle.setText(title[position]);
    holder.txtViewDescription.setText(description[position]);



  return convertView;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:20:51+00:00Added an answer on May 24, 2026 at 4:20 pm

    getView() : As mentioned in specs getView method displays the data at the specified position. So, when you setAdapter and when you scroll your listView getView method will be called.

    The method you copied here is a part of EfficientAdapter to optimize your ListView performance and along with optimization you used ViewHolder pattern.

    Copied from Specs : With little more explanation

    position :The position of the item within the adapter’s data set of the item whose view we want.

    convertView: The old view to reuse, if possible. Note: You should check that this
    view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. Heterogeneous lists can specify their number of view types, so that this View is always of the right type (see getViewTypeCount() and getItemViewType(int)).

    So, in above method when you are doing the following thing you are reusing your convertView.

         if (convertView == null){
                ....
                convertView.setTag(holder);
         } else {
               holder = (ViewHolder) convertView.getTag(); 
          }
    

    And by doing following thing you are avoiding lookup (findViewById), thats what the good thing about ViewHolder pattern

          holder.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1);
    

    parent : The parent that this view will eventually be attached to

    Edited

    Question : How many times getView is called and how many convertView will be created ?
    Answer: Lets take an example of Efficeint Adapter from ApiDemos. If your screen showing 10 Rows, then,

    convertView Count : 10 + 1 = 11 (10 Rows what you are seeing on screen, one extra to show scrolling effect). That means statements in if(convertView == null){…} block will be called only 11 times.

    getView Count: Initially count will be 10, but when you start scrolling count keep on increasing. getView called every time to update data.

    Note: This is only true for getView method mentioned in question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I went through http://platform.netbeans.org/tutorials/nbm-quick-start.html#lookup , but when I define the dependencies, it doesn't get
I went through the tutorial here: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application , and I can get a graph
Yes, I've read the developer documentation and even went through a few tutorials... but
I went through some tutorials on the State monad and I think I got
I just went through some MVC tutorials after checking this site out for a
I've signed up for Urban Airship and went through all of the tutorials and
I went through answers on similar topics here on SO but could't find a
I've went through the basic tutorials associated with Silverlight and Ria Services and I
Ok, this is really really easy, but even though I went through 100s of
Am stumbled - went through docs, tutorials, etc, and am not sure what I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.