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 7193757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:14:05+00:00 2026-05-28T20:14:05+00:00

I want to have a Listview adapter where each rows uses it’s own convertview,

  • 0

I want to have a Listview adapter where each rows uses it’s own convertview,
so this convertview couldn’t be share to another row.
Basically, if I have 4 rows, I would like to have 4 convertview.
And when drawing the row #3 I should get the convertview #3

To do this I setted each row a different type (it’s position)
I thought it would do the trick.

public class myadapter extends BaseAdapter {
final List<String> mdata;

@Override
public int getCount() {
    return mdata.size();
}

@Override
public Object getItem(int p) {
    return p;
}

@Override
public long getItemId(int p) {
    return p;
}

@Override
public int getItemViewType(int p) {
    return p;
}

@Override
public int getViewTypeCount() {
    return mdata.size()  == 0  ? 1 :mdata.size() + 1;
}

@Override
public View getView(int p, View v, ViewGroup arg2) {
    ViewHolder holder = null;
    if (v == null) {
        v = li.inflate(R.layout.data, null);
        holder = new ViewHolder();
        holder._pos = p;
        Log.v("TAG", "creating holder pos " + p + " for " + mdata.get(p));

        {...}

        v.setTag(holder);
    } else {
        holder = (ViewHolder)v.getTag();
        Log.d("TAG", "get convert for " + mdata.get(p)+ " holder " + holder._pos);

    }
    {...}
    return v;
}
public static class ViewHolder {
    public TextView _textView;
    public int _pos;
}
}

Note the pos in the viewholder is only here to debug purpose.

Unfortunatly it displays:

creating holder pos 0 for string0
creating holder pos 1 for string1
get convert for string0 holder 1
get convert for string0 holder 0
get convert for string1 holder 1

How the get convert for string0 holder 1 is possible ?

Thanks

  • 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-28T20:14:05+00:00Added an answer on May 28, 2026 at 8:14 pm

    I found the problem,

    getViewTypeCount()
    

    could not change during the execution of the program.
    You have to set it to a big value, even if you use less. It has to be a constant.

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

Sidebar

Related Questions

I have a ListView which uses a custom adapter to display rows of data.
I have a ListView whose rows are formatted by me. Each row has a
I have a listView using a custom adapter. Each row contains a button and
I want to display a ListView in table format. The ListView should have rows
I have a listview with each row having a checkbox, imageview and text view
Hi i want to set different images to each row of a listview which
I want to have a list of elements (using a ListView) and each element
I have a simple ListView and I want each of it items to be
I have a custom adapter that visualize each row in the list of Orders.
I have a ListView with BaseAdapter and I create this adapter in my main

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.