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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:03:52+00:00 2026-05-30T01:03:52+00:00

How do i update listivew when async task is done. Below is the sample

  • 0

How do i update listivew when async task is done. Below is the sample code but the listview isn’t updated.

    class CallXML extends AsyncTask<Void, Void, Void> {
    int gcid;
    int scid;

    public CallXML(int gid, int sid) {
        // TODO Auto-generated constructor stub
        gcid = gid;
        scid = sid;
    }

    protected void onPreExecute() {

    }

    protected Void doInBackground(Void... arg0) {
        // here goes the xml parsing....
        }   

        return null;            
    }

    protected void onPostExecute(String result) {  
       Log.e("TAG", "In postExecute");


       Cursor cur3 = database2.query("Quote", qfield,  null, null, null, null, null);
       cur3.moveToFirst();

       do {
        quotesarray.add(cur3.getString(2));

       }  while (cur3.moveToNext());

        if(cur3 != null){
            cur3.close();
        }

        QList.post(new Runnable() {
             public void run() {
                mAdapter = new CustomAdapter();
                mAdapter.notifyDataSetChanged();
                QList.setAdapter(mAdapter);    
             }
         });


        if (helper2 != null) {
            helper2.close();
        }

        if (database2 != null) {
            database2.close();
        } 

    }
}

EDIT:

Acutally onPostExecute is not executed why..This is the way I call asynctask new CallXML(gcid, scid).execute();

  • 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-30T01:03:53+00:00Added an answer on May 30, 2026 at 1:03 am

    Also, onPostExecute is on the main thread so should not be doing database queries there. Instead, get data in doInBackground and return the final collection from there.

    onPostExecute can be used for UI updates and updating your adapter with result collection.

    Edit: posting a runnable

     QList.post(new Runnable() {
                     public void run() {
                        //mAdapter.notifyDataSetChanged();
                        QList.setAdapter(mAdapter);    
                     }
                 });
    

    is not required since you are in the main loop.

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

Sidebar

Related Questions

Update: Solved, with code I got it working, see my answer below for the
I have a ListView inside of an Update Panel and wanted to change the
I have a listview which has its datasource changed after update of a search
UPDATE - A comprehensive comparison, updated as of February 2015, can be found here:
Hi I'm having problem refreshing my listview after Async operation. I have a simplecursoradapter,
I am trying to update the ListView with timer . I have implemented the
I am wondering how I can update my listview in form1 by entering data
I have a Form with a listview. After calling Form.Show I need to update
I want to periodically updated a ListView in a ListActivity. I know I can
How to auto scroll down in ListView control when update new item? I have

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.