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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:26:40+00:00 2026-05-22T21:26:40+00:00

Could someone explain me where the following problem is coming from: I have a

  • 0

Could someone explain me where the following problem is coming from:

I have a list that displays several items according to some preferences . The user can change these preferences through a SlidingDrawer . Whenever this happens I get the items corresponding to the new preferences and then I the set the result to the adapter backing the listview with the code below.

 public void update(final List<Report> reports)
 {
       adapter.setReports(reports);
       ((ArrayAdapter)list.getAdapter()).notifyDataSetChanged();
       list.invalidate();
 }

Here’s the adapter class

public class ReportsAdapter extends ArrayAdapter<Report>
{
    List<Report> reports;
    Activity context;

    public void setReports(List<Report> reports)
    {
        this.reports = reports;
    }

    ReportsAdapter(Activity context, List<Report> reports)
    {
        super(context, R.layout.row_report, R.id.report_timestamp,reports) ;

        this.reports = reports;
        this.context = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        View row = context.getLayoutInflater().inflate( R.layout.row_report, null);

        TextView timestamp = (TextView)row.findViewById(R.id.report_timestamp);
        if(timestamp != null)
            timestamp.setText("Timestamp: "+reports.get(position).getTimestamp());

        TextView type = (TextView)row.findViewById(R.id.report_type);
        if(type != null)
            type.setText("Type: "+reports.get(position).getReportType().getType().toString());

        TextView status = (TextView)row.findViewById(R.id.report_status);
        if(status != null)
           status.setText("Status: "+reports.get(position).getStatus());

        ImageView icon = (ImageView)row.findViewById(R.id.report_icon);
        if(icon != null && reports.get(position).getReportType().getType()!= ReportType.RType.DEFAULT)
        {
            Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), reports.get(position).getIconResource());
            if(bitmap != null)
            {
                icon.setImageBitmap(bitmap);
            }
        }        
        return row;
    }
}

After that the application crashes with an ArrayOutOfBoundsException in the adapter.

  • 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-22T21:26:41+00:00Added an answer on May 22, 2026 at 9:26 pm

    Hmmmm what does your custom Adapter extend from? You’re probably not updating the same Array/List that the getCount() is getting its size from. Or maybe there’s another problem with your getCount() implementation. I’ve found through practice that the safest way to get an Adapter working properly is to just extend from BaseAdapter and fill in any of the methods that the compiler asks you to.

    Incidentally, you don’t have to get the adapter through the list (since it’s the same as adapter, hopefully), so you can do adapter.notifyDatasetChanged() directly.

    If this doesn’t solve your problem, consider posting your adapter code.

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

Sidebar

Related Questions

Could someone explain me why do I have the following result with the following
I'm rather new to these could someone explain the significance (of the following code)
Could someone explain what I am doing wrong with my classes that my JTabbedPane
Let me explain my problem, and hopefully someone can offer some good advice. I
I am relatively new to Python and was hoping someone could explain the following
Could someone explain the best way to achieve the following, I think it's a
Could someone explain why pow() in the following code is returning a 0 when
Could someone please explain why this is happening; this following is the code I’ve
Could someone explain to me in simple terms the easiest way to change the
Could someone explain? I understand the basic concepts behind them but I often see

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.