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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:42:48+00:00 2026-06-13T12:42:48+00:00

I have a list view, populated with several ListItems. I also have an Option

  • 0

I have a list view, populated with several ListItems. I also have an Option Menu, which includes “Delete all items” button. When I hit this button, it calls for a method that deletes all items except the default and should also refresh the ListView.
This is the menu code:

public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId())
    {
        ...
        case R.id.optMenuDeleteAllCategories:
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Are you sure you want to delete all categories?")
            .setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    **deleteAllCategories();**
                }

This is the deleteAllCategories() method:

 public void deleteAllCategories()
{
    manager.deleteAllCategories();
    adapter.notifyDataSetChanged();
}

So it does delete everything, but the ListView doesn’t refresh. I have to quit the app and reopen it to see the change. I also tried to put the adapter.notifyDataSetChanged(); line right after calling for deleteAllCategories method, but the ListView still didn’t refresh.

So how can I refresh it without quitting the app?

  • 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-13T12:42:49+00:00Added an answer on June 13, 2026 at 12:42 pm

    Call adapter.clear() inside the deleteAllCategories method to also delete the items from the list.

    Edit: The ArrayAdapter internally will work on different list instances then the one you passed in. So while changes to the objects inside your original list will be reflected, changes to the ArrayList you passed in will not be visible to the adapter.

    You need to use the add, insert, remove and clear methods of the ArrayAdapter to modify the list in the adapter.

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

Sidebar

Related Questions

I have a list view which is populated via records from the database. Now
I have two activities. In activity1 , I have list view which is populated
I have a list view which is populated from a SQL database. I am
i see a weird bug here.. i have a list view which is populated
I have a list view with 5 columns which is populated via a stored
I have a list view, the contain is populated from a database. And I
I'm building an asp.net MVC 2 app. I have a list view which lists
I have a top list view in my current iPhone app, that's populated by
I have the following XML file getting populated via list view. I can't get
In my winforms app, I have a list view control that is populated with

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.