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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:05:01+00:00 2026-06-14T03:05:01+00:00

I am using View Pager for showing 3 Fragments in an activity(Dashboard.java). The activity

  • 0

I am using View Pager for showing 3 Fragments in an activity(Dashboard.java). The activity is loaded after clicking a button on previous activity(Login.java) and two of the fragments are showing a listview which is fetched from the server.

The problem is that it will take at least 3-7seconds to fetch the data from the server and populate as the listview. So I want to show a ProgressDialog to show a Loading status.

I have tried AsyncTask to load the data from the server in the fragment. It works but it show ProgressDialog only after a few time, just for a second before the list is populated. Also there is a delay on clicking the BUTTON to load the main Activity (Dashboard.java)

So there are two problems:
1. The progress dialog is appearing very late
2. There is a delay on the previous activity(Login.java) to MainActivity(Dashboard.java) (sometimes show black screen)

This is my AsyncTask in Fragment

new AsyncTask<Void, Void, Void>() {

            @Override
            protected void onPostExecute(Void result) {

                    pd.dismiss();
                super.onPostExecute(result);
            }

            @Override
            protected void onPreExecute() {
                pd.show();
                super.onPreExecute();
            }

            @Override
            protected Void doInBackground(Void... params) {


                NodeList nl = doc.getElementsByTagName(KEY_ITEM);
                // looping through all item nodes <item>
                for (int i = 0; i < nl.getLength(); i++) {
                    // creating new HashMap
                    HashMap<String, String> map = new HashMap<String, String>();
                    Element e = (Element) nl.item(i);
                    // adding each child node to HashMap key => value
                    map.put(KEY_ID, parser.getValue(e, KEY_ID)); // id not using any
                                                                    // where
                    map.put(KEY_NAME, parser.getValue(e, KEY_NAME));

                    // adding HashList to ArrayList
                    menuItems.add(map);
                }

                                return null;
            }
        }.execute();

Actually where do i should use the ProgressDialog, on MainActivity (Dashboard.java) or Fragment.java ?
Please guide me to the right path.

EDIT
Actually what is the best way to load fragments with a progress dialog?
(The fragments are listview which populated from the server)

  • 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-14T03:05:02+00:00Added an answer on June 14, 2026 at 3:05 am

    Nevermind, it was my mistake to write a method out side the doInBackground()

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

Sidebar

Related Questions

I am using the web view for showing html pages, and I want to
Iam devloping web application with mvc3.In one my view iam using WebGrid.In webgrid pager
I'm using a ViewPager to scroll between different fragments. There are two types of
I have an iPhone application where i'm showing a settings page using modal view
I'm trying to create a page by using view 2. This page list all
When using $route['(:any)'] = 'pages/view/$1'; and I want to use other controllers in my
I'm developing a single-page view for a resource that contains multiple nested resources. Using
I'm using Spree 0.70. In my home page view, I have the following to
I using coda slider in my page. View it here: http://www.ndoherty.com/demos/coda-slider/1.1.1/ Each tab causes
I am using a stored procedure to make page-navigation when I view a list

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.