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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:36:18+00:00 2026-05-26T23:36:18+00:00

I am using a TabActivity with 4 separate Activities – one for each tab.

  • 0

I am using a TabActivity with 4 separate Activities – one for each tab.

One of the Activities is a ListView that has a custom ArrayAdapter.

The issue is that when I press the Tab to change to this view, the Activity loads the content in before the view changes, this appears as though nothing happens for a couple of seconds until the xml is loaded and parsed etc.

I have looked for an example but this is my first Android appllication and I am having difficulty in understanding the flow.

Can anyone point me to some code that will allow me to instantly change the view (I can inform user content is loading) while loading the content in the background thread

thank you

EDIT – I am porting code over from an existing iOS app – I wasn’t able to better articulate the problem as I didn’t realise how the UI thread could be blocked in this situation, and due to the complexity of the existing code and deadline I didn’t want to change the structure too much.

I narrowed down the issue before I saw your code Jennifer but it is the solution I used so Ill mark yours as right.

here is what I used if it helps anyone else, I had to put the function I called to trigger the data load onto a background thread and then display the content when that thread had done its work

This class was declared within my

public class TableView extends ListActivity

Which was hard for me to get my head around having not done this before 😉

public class GetContentTask extends AsyncTask<Void, Void, Void> {


    private ProgressDialog pdialog;

    @Override
    protected void onPreExecute(){ 
       super.onPreExecute();
       pdialog = new ProgressDialog(TableView.this);
       pdialog.setTitle(progressDialogTitle);
       pdialog.setMessage(progressDialogMessage);
       pdialog.show();    
    }

    @Override
    protected void onPostExecute(Void result){
       super.onPostExecute(result);
       setUpAndLoadList(); // the function to display the list and fill it with content
       pdialog.dismiss();
    }


    @Override
    protected Void doInBackground(Void... params) {
        doInitialLoad(); // The function to load any xml data from server
        return null;
    }
 }
  • 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-26T23:36:18+00:00Added an answer on May 26, 2026 at 11:36 pm

    You can use a progress Dialog (can inform user content is loading)

    ProgressDialog dialog;
    
    private class XMLOperation extends AsyncTask<String, Void, String> {
    
    /*
         * (non-Javadoc)
         * 
         * @see android.os.AsyncTask#onPreExecute()
         */
        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
            super.onPreExecute();
    
            System.out.println("onPreExecute");
    
            dialog= ProgressDialog.show(mContext, "", "Loading Content....");
                  dialog.setCancelable(false);
    
    
        }
    
    
    
    
            @Override
        protected String doInBackground(String... urls) {
    
                //do your Background task
    
        }
    
    
    
    
    protected void onPostExecute(String result) {   //dismiss dialog
            try {
    if(dialog.isShowing()){
            dialog.dismiss();
            }
    
    
    
            } catch (Exception exception) {
            dialog.dismiss();
            }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i found that when using android TabActivity to open tabs where each tab is
My app starts with a TabActivity that has three activities associated to it, one
Possible Duplicate: Separate Back Stack for each tab in Android using Fragments I've recently
I have a tabactivity with several tabs. Each tab has an ActivityGroup associated with
I am using TabActivity for my application. It has 4 tabs. Tab 1 is
I currently have a TabActivity which has 4 tabs, within one of the tab's
I have a TabActivity where each tab has ActivityGroup. On the home ActivityChild of
Using C#, I need a class called User that has a username, password, active
I have been using TabActivity and I want the tab to display on every
I currently have this code that creates 4 tabs using tabactivity: public class toknapp

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.