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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:43:03+00:00 2026-06-08T09:43:03+00:00

I have a custom ArrayAdapter I use to manage my ListView: public class FilesAdapter

  • 0

I have a custom ArrayAdapter I use to manage my ListView:

public class FilesAdapter extends ArrayAdapter<PutioFileLayout> {

    Context context;
    int layoutResourceId;
    PutioFileLayout data[] = null;

    public FilesAdapter(Context context, int layoutResourceId, PutioFileLayout[] data) {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        FileHolder holder = null;

        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new FileHolder();
            holder.textName = (TextView) row.findViewById(R.id.text_fileName);
            holder.textDescription = (TextView) row.findViewById(R.id.text_fileDesc);
            holder.imgIcon = (ImageView) row.findViewById(R.id.img_fileIcon);

            row.setTag(holder);
        } else {
            holder = (FileHolder) row.getTag();
        }

        PutioFileLayout file = data[position];
        holder.textName.setText(file.name);
        holder.textDescription.setText(file.description);
        holder.imgIcon.setImageResource(file.icon);

        return row;
    }

    static class FileHolder {
        TextView textName;
        TextView textDescription;
        ImageView imgIcon;
    }
}

And in my Fragment, I declare these before the onCreate:

private PutioFileLayout[] fileData;
private FilesAdapter adapter;

Then, in the onCreate, I initialize it with this, as a placeholder for the user:

    fileData = new PutioFileLayout[] {
            new PutioFileLayout("Loading...", "Your files will appear shortly.", R.drawable.ic_launcher, false)
    };

And I initialize my adapter:

    adapter = new FilesAdapter(getSherlockActivity(), R.layout.file,
            fileData);
    listview.setAdapter(adapter);

Later, after some network stuff, I update the adapter’s data. This is where I think I might be going wrong.

PutioFileLayout[] files = blah blah, stuff. I've confirmed in debug that this array is correct and has the correct number of values.
adapter.data = files;
                adapter.notifyDataSetChanged();

The result of all that is the ListView showing the very first item in the array, and nothing else.

If I add a second Loading… row or similar when I initialize it, it shows the first two. Etcetera.

Am I missing something? What’s the proper way to do this?

  • 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-08T09:43:06+00:00Added an answer on June 8, 2026 at 9:43 am

    If you want to update ArrayAdapter use ArrayList instead of Array. Because if you are using Array, ArrayAdapter will use List internally which can’t be updated.

    Rewrite your constructor

    public FilesAdapter(Context context, int layoutResourceId, List<PutioFileLayout> list) {
        super(context, layoutResourceId, list);
        ...
    }
    

    In getView() you get item by invoking getItem(position).

    To initialize your adapter use adapter = new FilesAdapter(getSherlockActivity(), R.layout.file, new ArrayList<PutioFileLayout>());

    And to fill your adapter use adapter.add(new PutioFileLayout(...));

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

Sidebar

Related Questions

I have a custom ArrayAdapter populating a ListView . Here it is: public class
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
I have created a custom ArrayAdapter to display data within ListView items from an
I want to have a listview with a custom adatper, extends ArrayAdapter, where Type
I have created a custom ArrayAdapter that fills a ListView . The data in
I have a ListView that has a custom ArrayAdapter with a custom XML row.
I have used ListView and bounded my custom ArrayAdapter to it. Have setOnItemClickListener(...) bound
I have a ListView that I want to use with an ArrayAdapter to add
I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides
I have a listview with a custom arrayadapter that handles about 15 strings. The

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.