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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:12:24+00:00 2026-05-26T19:12:24+00:00

In my listActivity , I am using setListAdapter(new ArrayAdapter<String>(this, R.layout.project_list, titles)); to set my

  • 0

In my listActivity , I am using

setListAdapter(new ArrayAdapter<String>(this, R.layout.project_list, titles)); 

to set my list view. now I want to sort this list on click of spinner for that i am using like it

spn_sort_order .setOnItemSelectedListener(new OnItemSelectedListener() {

   public void onNothingSelected(AdapterView<?> arg0) { }

   public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {

and to display the new results I need to refresh the old view.

Edit:

 public void onItemSelected(AdapterView<?> parent, View v,
                        int position, long id) {

                    sortBy = position;
                    System.out.println("selected item id:::priortiy::::"
                            + sortBy);
                    if (sortBy == 1) {
                        Collections.sort(titles);
                        System.out.println(titles);
                        setListAdapter(listAdapter);
                        listAdapter.notifyDataSetChanged();
                    }
                    if (sortBy == 2) {
                        Comparator<Object> comparator = Collections.reverseOrder();
                        Collections.sort(titles,comparator);
                        System.out.println(titles);
                        setListAdapter(listAdapter);
                        listAdapter.notifyDataSetChanged();
                    }

                }

when i click on first item in the list my data is sorted in ascending order and when i click on second item in the list data is sorted in descending order bcoz i used

Comparator<Object> comparator = Collections.reverseOrder();
  • 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-26T19:12:25+00:00Added an answer on May 26, 2026 at 7:12 pm

    It seems that you’re using an ArrayAdapter so I would recommend using arrayAdapter.notifyDataSetChanged()

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

Sidebar

Related Questions

So basically I want this list view to be shuffled so it is always
I have an Android app with a ListActivity in the main view. The list
If I want to remove an item from my list view by tapping it,
I am using this to retreive a list of items and place them in
I'm working on an application that lists a stored library using a ListActivity. My
I've populated a ListActivity from a Cursor using SimpleCursorAdapter that starts another activity when
I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a layout that creates a ListActivity. Before displaying the ListActivity, I perform
Without using listactivity, in a simple activity how can I have checkbox at the
Im using a ListActivity with a listview The problem is that for some reason,

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.