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

  • Home
  • SEARCH
  • 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 9318455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:07:57+00:00 2026-06-19T03:07:57+00:00

I currently have this class below which parses json urls and loads images and

  • 0

I currently have this class below which parses json urls and loads images and texts into a listview with the help of the Lazy Adapter Class and background thread.

Each list item consists of an image view and 2 text views.

I want to create pop up boxes (alert dialog) for each of the generated list items. The alert dialog will have options which will call other applications.

My question :

Would it be wise to code this alert dialog functionality in this class? I’m worried that there is a lot of stuff currently being done in the background and it might affect the app’s functionality.

If not could anyone suggest another way to do it. thanks.

Json Activity Class :

public class JsonActivity extends  SherlockActivity{

 private ProgressDialog progressDialog;

    // JSON Node names


   static final String TAG_NAME = "name";
   static final String TAG_IMAGEURL = "imageurl";

    ListView list;
    LazyAdapter adapter;

   String chartUrl;

    String[] urlNames = new String[] { 
            "urls..."

            };

 // chartItemList is the array list that holds the chart items 
    ArrayList<HashMap<String, String>> chartItemList = new ArrayList<HashMap<String, 
        String>>();

    //Holds imageurls 
    ArrayList<String> imageurls = new ArrayList<String>();


    JsonParser Parser = new JsonParser();
 // JSONArray
    JSONArray chartItems = null;

    /** Called when the activity is first created. */    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chart);

        //Get the bundle 
        Bundle bundle = getIntent().getExtras();

        //Extract the data from the bundle
        int chartIndex = bundle.getInt("chartIndex");
        String chartUrl = urlNames[chartIndex]; 

        setTitle(bundle.getString("chartname"));



        //url from where the JSON has to be retrieved
        String url = chartUrl;

        //Check if the user has a connection

        ConnectivityManager cm = (ConnectivityManager) 
            getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info = cm.getActiveNetworkInfo();
        if (info != null) {
            if (!info.isConnected()) {
                Toast.makeText(this, "Please check your connection and try again.", 
             Toast.LENGTH_SHORT).show();
            }

            //if positive, fetch the articles in background
            else new getChartItems().execute(chartUrl);
        }

        //else show toast
        else {
            Toast.makeText(this, "Please check your connection and try again.", 
            Toast.LENGTH_SHORT).show();
        }

    }


    class getChartItems extends AsyncTask<String, String, String> {

        // Shows a progress dialog while setting up the background task
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            progressDialog = new ProgressDialog(JsonActivity.this);
            progressDialog.setMessage("Loading chart...");
            progressDialog.setIndeterminate(false);
            progressDialog.setCancelable(false);
            progressDialog.show();
        }

        //Gets the json data for chart items data and presents it in a list view
        @Override
        protected String doInBackground(String... args) {

        String json = Parser.getJSONFromUrl(args[0]);
            String imageurl;
        String rank;
        String name;            
        String url;

            try{


            chartItems = new JSONArray(json);

            JSONObject json_data=null;

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

                json_data = chartItems.getJSONObject(i);

                //Retrieves the value of the name from the json object

                name=json_data.getString("name");

                //Retrieves the image url for that object and adds it to an arraylist
                imageurl=json_data.getString("imageurl");
                //imageurls.add(imageurl);

                 HashMap<String, String> hashMap = new HashMap<String, String>();
                 // adding each child node to HashMap key => value
                 //hashMap.put(TAG_RANK, rank);
                 hashMap.put(TAG_NAME, name);
                 hashMap.put(TAG_IMAGEURL, imageurl);


                 // adding HashMap to ArrayList
                    chartItemList.add(hashMap);

             }


              ;
            }

            catch (JSONException e) {
                e.printStackTrace();
            }

            runOnUiThread(new Runnable() {
                public void run() {


                    list=(ListView)findViewById(R.id.list);

                     // Getting adapter by passing xml data ArrayList
                     adapter = new LazyAdapter(JsonActivity.this, chartItemList);
                     list.setAdapter(adapter);

                     // Click event for single list row
                     list.setOnItemClickListener(new OnItemClickListener() {

                         @Override
                         public void onItemClick(AdapterView<?> parent, View view,
                                 int position, long id) {

                         }
                     });




                }
            });
            return null;
        }

        //Removes the progress dialog when the data has been fetched
        protected void onPostExecute(String args) {
            progressDialog.dismiss();
        }
    }

}

  • 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-19T03:07:58+00:00Added an answer on June 19, 2026 at 3:07 am

    My answer for this is Yes, it is wise enough to implement one more level network communication as far as your use case justifies it.

    This depends on communication channel (EDGE/ 3G/ 4G/ WiFi) and use case of the application. Technically it is pretty much possible as far as you are doing this in background. It also depends on the size of the list which you are loading. Best way to check this is by implementing plug-able code and try it out.

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

Sidebar

Related Questions

I currently have this code which stores XML into an XML-type column called data,
I currently have service classes that look something like this public class UserService :
Currently I have a class that looks like this: public class MyClass : IMyClass
I have something like this currently: <div class = className style = position: absolute;
I currently have this Custom ArrayList: ArrayList<PlaceDetails> place_list = new ArrayList<PlaceDetails>(); which will be
I currently have a tabview with 3 tabs. 1 tab loads an ActivityGroup which
I currently have an extension Method which converts an IEnumerable of type Tab into
Hope I'm asking this correctly: I have a project Projects.Client I have my class
i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul>
I currently have this sql statement that I wrote and it works but it's

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.