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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:26:02+00:00 2026-06-17T14:26:02+00:00

I have a custom ArrayAdapter. When data is displayed in ListViews I always want

  • 0

I have a custom ArrayAdapter. When data is displayed in ListViews I always want it sorted, therefore I tried to override notifyDataSetChanged() to sort the adapter first, like this:

@Override
public void notifyDataSetChanged() {
    sort(new Comparator<IceContact>() {
        @Override
        public int compare(IceContact iceContact, IceContact iceContact2) {
            return iceContact.compareTo(iceContact2);
        }
    });
    super.notifyDataSetChanged();
}

The class IceContact is a get-set class that implement Comparable. Unfortunately this is giving me a, ironically, StackOverflowError (logcat below). I then tried to do it the other way around. Override sort() and call notifyDataSetChanged() directly after, like this:

@Override
public void sort(Comparator<? super IceContact> comparator) {
    super.sort(comparator);
    notifyDataSetChanged();
}

That works just fine! Can anyone explain why? It feels like they are pretty much identical implementations.


01-21 18:25:50.725: ERROR/AndroidRuntime(2490): FATAL EXCEPTION: main
    java.lang.StackOverflowError
    at android.view.View.setFocusableInTouchMode(View.java:5584)
    at android.widget.AdapterView.checkFocus(AdapterView.java:717)
    at android.widget.AdapterView$AdapterDataSetObserver.onChanged(AdapterView.java:812)
    at android.widget.AbsListView$AdapterDataSetObserver.onChanged(AbsListView.java:6044)
    at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
    at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
    at android.widget.ArrayAdapter.notifyDataSetChanged(ArrayAdapter.java:286)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:70)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(IceContactAdapter.java:71)
    at android.widget.ArrayAdapter.sort(ArrayAdapter.java:278)
    at se.naxiait.curbits.utils.IceContactAdapter.notifyDataSetChanged(Ic
  • 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-17T14:26:03+00:00Added an answer on June 17, 2026 at 2:26 pm

    The class IceContact is a get-set class that implement Comparable.
    Unfortunately this is giving me a, ironically, StackOverflowError
    (logcat below).

    sort() calls be default(in its implementation) notifyDataSetChanged() which will then call again sort() which in turn will call notifyDataSetChanged() which will call sort() which will call…

    In the notifyDataSetChanged sort the data without also calling notifyDataSetChanged() as sort() will automatically do that for you.

    The second scenario will work as you’ll basically call notifyDataSetChanged() two times(super.sort(), sort the data->notifyDataSetChanged() from super call-> notifyDataSetChanged() call by you)

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

Sidebar

Related Questions

I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
i have a ListView (lvProperties) whose adapter is a custom ListAdapter (not an ArrayAdapter).
I have created a custom ArrayAdapter to display data within ListView items from an
I have a list which is filled with a custom ArrayAdapter . I want
I have a custom list adapter. Here it is: public class FilesAdapter extends ArrayAdapter<PutioFileLayout>
I have created a custom ArrayAdapter that fills a ListView . The data in
I have ListView with custom adapter extends ArrayAdapter. Each item is object: public class
This post will be heavy on images. I have created a custom ArrayAdapter and
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

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.