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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:31:28+00:00 2026-06-16T09:31:28+00:00

I have MainActivity which extends SherlockListActivity. Here is onCreate method: public void onCreate(Bundle savedInstanceState)

  • 0

I have MainActivity which extends SherlockListActivity. Here is onCreate method:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    new MyXMLDownloader().execute(this);
}

MyXMLDownloader is just AsyncTask class, which I use to download XML file from http. In onPostExecute method I’m calling makeMainGUI() which creates GUI based on that XML file (I mean it fills my ListView).

Here is main.xml:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <ListView
        android:id="@+android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>

I would like to add ProgressBar widget (and some text). It should be shown before downloading XML and it should disappear after ListView is filled (of course it happens after XML is downloaded). How can I achieve that?

I have problem with that, because I must have ListView in main.xml, because I MainActivity class extends SherlockListActivity.

EDIT:

I managed to do something like this:

<ProgressBar
        android:id="@android:id/empty"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

I added ProgressBar to main.xml with “empty” id. It is shown as long as ListView is empty, which is correct. But I don’t know how can I place a TextView here too because only one item can have an “empty” id.

EDIT2:
As I think I managed to do this. In main.xml I added following:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center" 
    android:id="@android:id/empty">
    <ProgressBar
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" 
    android:id="@+id/progressBar1"/>

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="Please wait"
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:id="@+id/waitingTextView"/>

</LinearLayout>

And it is something I needed. Thank you!

  • 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-16T09:31:30+00:00Added an answer on June 16, 2026 at 9:31 am

    In the AsyncTask class use onPrexecute method to display progress dialog and use onPostExecute to dismiss it:

    @Override
    protected void onPreExecute()
    {
        super.onPreExecute();
        pDialog = new ProgressDialog(YOUR_ACTIVITY_CLASS_NAME.this);
        pDialog.setMessage("Please Wait");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }
    
    @Override
    protected void onPostExecute(String str)
    {
        // Dismiss the dialog once finished
        pDialog.dismiss();  
    }
    

    Don’t forget to define pDialog before you call it:

    ProgresDialog pDialog;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(I have got class MainActivity (extends Activity) and there I have got method setContentView(GameView);
I have 2 tabs, named : Tab1, Tab2 class MainActivity extends TabActivity. MainActivity.java public
I have the following class: public class MainActivity extends Activity { /** Called when
I have a MainActivity class which extends SlidingMenu . When the user clicks in
I have two classes 1.MainActivity which extends Activity and 2.AlarmReceiver which extends BroadcastReceiver. How
I have an activity ( MainActivity.java ) in which content view is like this
I have a mainActivity which is Customer.java with listview of 5 diff. activities. I
I have an AsyncTask which calls my LocationHandler class method getLocation() which runs a
I'm just starting out in android and I have my MainActivity class which has
I have a Fragment called MeinProfilFragment . And a MainActivity which handles the ActionBar-Tabs

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.