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

  • Home
  • SEARCH
  • 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 8208229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:16:11+00:00 2026-06-07T09:16:11+00:00

I extended an ArrayAdapter with an overridden getView() method to fill my ListView object,

  • 0

I extended an ArrayAdapter with an overridden getView() method to fill my ListView object, but the adapter will grab the first two or three objects from the ArrayList I pass to it, then just repeat those in seemingly random order for the entire length of the list. Furthermore, when I scroll up and down in the ListView, some rows change from one list item to another. The ArrayList<Credit> object gets populated from a JSONObject, and to the best of my knowledge is correct prior to being passed into the ArrayAdapter.

My custom ArrayAdapter

private class CreditArrayAdapter extends ArrayAdapter<Credit> {
    private ArrayList<Credit> credits;
    private int creditCount;

    public CreditArrayAdapter(Context ctx, int textViewResourceId, List<Credit> items) {
        super(ctx, textViewResourceId, items);
        credits = (ArrayList<Credit>) items;
        creditCount = credits.size();
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list_item_movie_medium, null);
            Credit current = credits.get(position);
            Log.d(tag, "current credit: " + current.toString());
            ImageView creditPicture = (ImageView) v.findViewById(R.id.image_poster_thumbnail);
            try {
                creditPicture.setImageBitmap(current.getPosterSmall());
            } catch(Exception e) {
                Log.d(tag, "failed to set cast member picture");
                e.printStackTrace();
            }
            TextView castMemberName = (TextView) v.findViewById(R.id.text_credit_info);
            castMemberName.setText(current.toString());
        }
        return v;
    }
    @Override
    public int getCount() {
        return creditCount;
    }
}

being called by:

appearsIn = (ListView) findViewById(R.id.listview_appears_in);
List<Credit> credits = searcher.getCreditsByPersonId(personId);
CreditArrayAdapter creditAdapter = new CreditArrayAdapter(getBaseContext(), R.layout.list_item_movie_medium, credits);
creditAdapter.notifyDataSetChanged();
appearsIn.setAdapter(creditAdapter);

The layout containing the ListView:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:layout_centerHorizontal="true"
              android:weightSum="2">
    <ScrollView android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1">
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:orientation="vertical">
            <ImageView android:id="@+id/image_person_info"
                       android:layout_height="wrap_content"
                       android:layout_width="wrap_content"
                       android:contentDescription="person image"/>
            <TextView android:id="@+id/text_person_name"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textSize="30dp"/>
            <TextView android:id="@+id/text_person_birth"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textSize="20dp"/>
            <TextView android:id="@+id/text_person_death"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textSize="20dp"/>
            <TextView android:id="@+id/text_person_bio"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textSize="16dp"/>
        </LinearLayout>
    </ScrollView>

    <ListView android:id="@+id/listview_appears_in"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:layout_weight="1"/>
</LinearLayout>

My list item layout:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="horizontal">
    <ImageView android:id="@+id/image_poster_thumbnail"
               android:layout_height="wrap_content"
               android:layout_width="wrap_content"/>
    <TextView android:id="@+id/text_credit_info"
              android:layout_height="wrap_content"
              android:layout_width="fill_parent"/>
</LinearLayout>
  • 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-06-07T09:16:14+00:00Added an answer on June 7, 2026 at 9:16 am

    change the getView like this:

    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list_item_movie_medium, null);
        }
        Credit current = credits.get(position);
        Log.d(tag, "current credit: " + current.toString());
        ImageView creditPicture = (ImageView) v.findViewById(R.id.image_poster_thumbnail);
        try {
           creditPicture.setImageBitmap(current.getPosterSmall());
        } catch(Exception e) {
            Log.d(tag, "failed to set cast member picture");
            e.printStackTrace();
        }
        TextView castMemberName = (TextView) v.findViewById(R.id.text_credit_info);
        castMemberName.setText(current.toString());
    
        return v;
    }
    

    Your problem was you were not doing all the code you needed to set the View object correctly when convertView was != null.

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

Sidebar

Related Questions

I have succesfully extended a view and overridden the onDraw() method I can draw
I extended jquery object directly with a tween method. Does this apply to all
I extended JDialog to create a custom dialog where the user must fill some
I extended the functionality of a line object using a class which takes a
I've extended the Backbone Collection class to include a save method, which is essentially
I extended RegistrationFormUniqueEmail class CustomRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): first_name = forms.CharField(label=_('First name'), max_length=30,required=True) last_name = forms.CharField(label=_('Last name'),
I extended a View and call the invalidate() method to force redrawing. I only
An extended class with BaseAdapter will not allow me to jump from one activity
I extended SimpleCursorAdapter according to my needs. I want to show two textviews in
I have extended PHP's mysqli class, which works fine. But how can I make

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.