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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:30:56+00:00 2026-05-23T15:30:56+00:00

I have a ListView view I need to populate using data I am fetching

  • 0

I have a ListView view I need to populate using data I am fetching from a server. The fetching of the data is done in a AsyncTask background thread.

            ListView view = new ListView(RestaurantInfo.this);
            CustomAdapter adapter = new CustomAdapter(RestaurantInfo.this, R.layout.restaurant_info, R.id.dish_name, data); 
            view.setAdapter(adapter);
            LinearLayout layout = (LinearLayout) findViewById(R.id.restaurant_info_layout);
            Button theView = new Button(RestaurantInfo.this);
            layout.addView(theView);

The exact same code works – loads the items into the activity if above code is placed in the onCreate function (which causes the app to block and become unresponsive until the server serves the request). Why does this not work when the same code is placed in the onPostExecute of a AsyncTask?

  • 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-23T15:30:56+00:00Added an answer on May 23, 2026 at 3:30 pm

    Do you call adapter.notifyDataSetChanged() when you finish loading your data ? This is needed to notify the listView that it should refresh, and should be done in your AsyncTask’s postExecute method.

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

Sidebar

Related Questions

Currently I have a ListView (using the Details View). I would like to implement
tl;dr: I need to show data from two different tables in the list view
I have a custom control that is derived from ListView . This list view
i ma using am listview and datapager control. in my list view i have
I have a class A which is responsible for fetching data from web services
In a WPF application I have a ListView: <ListView Name=ItemSelList ItemsSource={Binding ItemColl} SelectionChanged=ItemSelList_SelectionChanged> <ListView.View>
I have a ListView whose size is fixed to maximum of 10 items View
I have a listview with 200 items. I use a custom view for each
I have a list view filled with data. I set up a context menu
I currently have a list view which has several rows of data and I

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.