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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:36:57+00:00 2026-05-25T21:36:57+00:00

I need to load load text in list but first it should load an

  • 0

I need to load load text in list but first it should load an empty list in that time it should display a progress bar. I fetch all the contents from the json feeder. But am stuck with how to load the empty list when the process is in backgroud.

/**
 * This class loads MainScreen in ListView
 */
package com.smartmedia.salonaudi;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.smartmedia.salonaudi.map.GoogleMapActivityClass;

/**
 * 
 * 
 * 
 */
public class SalonAudiActivity extends ListActivity {

    Button map;
    Button left;
    Button about;
    final Handler uiThreadCallback = new Handler();
    Runnable runInUIThread;
    // WebView about;

    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
    ArrayList<HashMap<String, String>> mylistCopy = mylist;
    ArrayList<String> latitude = new ArrayList<String>();
    ArrayList<String> longitude = new ArrayList<String>();

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.listplaceholder);
        //processDialog = ProgressDialog.show(this, "", getString(R.string.loading), true);
         // getDetails();
        // Map Button Click
        map = (Button) findViewById(R.id.seeonmap);

        map.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(SalonAudiActivity.this,
                        GoogleMapActivityClass.class);


                intent.putExtra("latitude", latitude);
                intent.putExtra("longitude", longitude);
                startActivity(intent);
            }
        });

        // Live Button Click
        about = (Button) findViewById(R.id.about);

        about.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri
                        .parse("http://google.com"));
                startActivity(intent);

            }
        });

        JSONObject json = JSONfunctions
                    .getJSONfromURL("http://audi.smart-media.no/api/getEvents.php");

            try {

                JSONObject es = json.getJSONObject("events");
                JSONArray event = es.getJSONArray("event");
                JSONObject[] events = new JSONObject[es.length()];

                for (int i = 0; i < event.length(); i++) {

                    HashMap<String, String> map = new HashMap<String, String>();
                    JSONObject e = event.getJSONObject(i);
                    map.put("id", String.valueOf(i));
                    map.put("Time", "" + e.getString("startTime").split(" ")[0]);
                    map.put("startTime",
                            ""
                                    + e.getString("startTime").split(" ")[1]
                                            .substring(0, 5)
                                    + " @ Olympic Stadium");

                    map.put("title", "" + e.getString("title"));
                    System.out.println("title" + e.getString("title"));
                    map.put("ingress", "" + e.getString("ingress"));
                    map.put("description",
                            ""
                                    + e.getString("description").replaceAll(
                                            "\\<[^>]*>", ""));
                    map.put("image", "" + e.getString("image"));
                    map.put("latitude", "" + e.getString("latitude"));
                    map.put("longitude", "" + e.getString("longitude"));

                    System.out.println("latitude" + e.getString("latitude"));
                    mylist.add(map);

                }

            }

            catch (JSONException e) {
                Log.e("log_tag", "Error parsing data " + e.toString());
            }



        ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.main,
                new String[] { "startTime", "title", "description" },
                new int[] { R.id.time, R.id.title, R.id.description });

        setListAdapter(adapter);

        final ListView lv = getListView();

        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                Intent intent = new Intent();
                intent.setClassName(SalonAudiActivity.this,
                        "com.smartmedia.salonaudi.DetailView");

                HashMap<String, String> map = mylistCopy.get(arg2);
                intent.putExtra("title", map.get("title"));
                intent.putExtra("image", map.get("image"));
                intent.putExtra("startTime", map.get("startTime"));
                intent.putExtra("ingress", map.get("ingress"));
                intent.putExtra("description", map.get("description"));
                startActivity(intent);
            }

        });

        for (int i = 0; i < mylist.size(); i++) {
            HashMap<String, String> e = mylist.get(0);
            latitude.add(e.get("latitude"));
            longitude.add(e.get("longitude"));
        }
    }

    public boolean isConnected() {
        Context context = getApplicationContext();
        ConnectivityManager connectivity = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (connectivity == null) {

        } else {
            NetworkInfo[] info = connectivity.getAllNetworkInfo();
            if (info != null) {
                for (int i = 0; i < info.length; i++) {
                    if (info[i].getState() == NetworkInfo.State.CONNECTED) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

}
  • 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-25T21:36:58+00:00Added an answer on May 25, 2026 at 9:36 pm

    You have to use AsyncTask for displaying dialog box while data is loading in the list.

    Definitely this will solve your problem

    There is code … This will help you to do Your work…

    In doInBackground method load all ur json data into arrays or ArrayList and set into the adpater

    In PostExecute method , set the adapter to your list..

    private class LoadingData extends AsyncTask<String, Void, String> {
    
            private ProgressDialog Dialog = new ProgressDialog(getParent());
    
            @Override
            protected String doInBackground(String... params) {
            // perform long running operation operation
            //Here you have to do your network operations..
    
            return null;
            }
    
    
            @Override
            protected void onPostExecute(String result) {
            // execution of result of Long time consuming operation
    
            try
                 {
                      if(Dialog.isShowing())
                      {
                          Dialog.dismiss();
                      }
                      // do your Display and data setting operation here
                 }
                 catch(Exception e)
                 {
    
                 }
            //Here depending upon your validation, display appropriate message. 
                }
    
            @Override
                protected void onPreExecute() {
                Dialog.setMessage("Loading Data.....");
                Dialog.show();
    
            // Things to be done before execution of long running operation. For example showing ProgessDialog
    
            }
    
            @Override
            protected void onProgressUpdate(Void... values) {
            // Things to be done while execution of long running operation is in progress. For example updating ProgessDialog
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big load of documents, text-files, that I want to search for
Maybe that's not exactly the solution i need, but this is what i want
I'm currently designing a website that would involve storing a long list of names
I have a jQuery AJAX data grid that loads a list of elements from
I am using a Listview in a usercontrol that I databind to a list
I have a nested simple XML structure that I load with PHP's simpleXML. Some
i have a new question. i have a code to load a list from
I have a form with a list box and a few text boxes, when
Ok. What I wanted was: With Hibernate, to load once a list of MyEntity
I am working on a desktop application for which I need to load the

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.