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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:43:36+00:00 2026-05-27T14:43:36+00:00

I am doing lazy loading and almost done with it. But would like to

  • 0

I am doing lazy loading and almost done with it. But would like to implement a progress dialog with it because it takes about 10seconds between starting the activity and finishing displaying the contents. Once I click on a button to start, it stays at the current page(Main.java) for about 4 second before moving to the next page(Activity.java). Then it takes about 2-4 seconds to display contents.

Tried the examples available here and on the net but they aren’t working well (able to display the dialog but unable to do a proper dismiss after content are all downloaded).

Question is, how can I implement a progress indicator immediately once the user clicks on the button?

Activity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);        

    list=(ListView)findViewById(R.id.list);           
    adapter=new LazyAdapter(this, mStrings, dStrings );
    list.setAdapter(adapter);
}    

private String[] mStrings = {};
private String[] dStrings = {};

public Activity()
{
    String imageC = "";
    String textC = "";

    try {
        // Get the URL from text box and make the URL object

        URL url = new URL(targetURL);

        // Make the connection
        URLConnection conn = url.openConnection();
        BufferedReader reader = new BufferedReader(
         new InputStreamReader(conn.getInputStream()));

        String line = reader.readLine();
        Pattern sChar = Pattern.compile("&.*?;");
        Matcher msChar = sChar.matcher(line);
        while (msChar.find()) line = msChar.replaceAll("");

        while (line != null) {

            if(line.contains("../../"))
            {

                int startIndex = line.indexOf("../../") + 6;
                int endIndex = line.indexOf(">", startIndex + 1);
                String abc = "http://www.petschannel.com/";
                String imageSrc = line.substring(startIndex,endIndex);
                //complete full url
                String xyz = abc +imageSrc;
                xyz = xyz.substring(0,xyz.indexOf('"'));
                xyz = xyz +";";
                imageC += xyz;                  
                mStrings = imageC.split(";");
                line = reader.readLine();
            }

            if(line.contains("../../") == false)
            {
                line = reader.readLine();
            }

            if (line.contains("Gnametag"))
            {
                int startIndex = line.indexOf("Gnametag") + 10;
                int endIndex = line.indexOf("<", startIndex + 1);
                String gname = line.substring(startIndex,endIndex);
                textC += "Name: "+gname+ "\n";
            }               

            if (line.contains("Last Update"))
            {
                reader.close();
            }                               
        }           

        // Close the reader
        reader.close();

    } catch (Exception ex) {
        ex.printStackTrace();           
    }   
}    
  • 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-27T14:43:36+00:00Added an answer on May 27, 2026 at 2:43 pm

    Firstly, you are doing your network call on the main thread, this is a classic no-no for performance reasons, amongst others. Never do any operation that may be time consuming on the main (ui) thread.

    I would suggest using AsyncTask, which ensures in this case, that your network call would be done in a worker thread, and the result posted back to the main thread.

    AsyncTask has methods to manage progress bars, onProgressUpdate and publishProgress that will help you solve your stated problem. There are many good articles about this, here is one.

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

Sidebar

Related Questions

I have some entity types that I would like to lazy load. However, they
I have a Treeview which is doing lazy loading. I used MVVM. I wanted
I am trying to globally disable Fluent NHibernate lazy-loading features, but even after: LazyLoad.Never();
I'm doing some lazy loading of images into an array when the app has
I think i'm missing something fundamental about how Hibernate works, specifically with lazy loading.
I just want to ask, how to prove that hibernate is doing lazy loading
When doing small icons, header graphics and the like for websites, is it better
Is there more elegant way of doing lazy evaluation than the following: pattern='$x and
Apple just released some sample code on lazy loading images in a UITableView a
I am designing a helper method that does lazy loading of certain objects for

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.