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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:57:55+00:00 2026-06-01T02:57:55+00:00

I have a json feed from this URL which contains 20 fields and I

  • 0

I have a json feed from this URL which contains 20 fields and I parse all the datas..but again I need to load more data from the json feed after showing the 20 fields in listview.

I have created a AsyncTask and loaded the json in listview. this is my class

public void onCreate(Bundle savedInstanceState) {
new DoInBackgrd().execute();
}

    private class DoInBackgrd extends AsyncTask<Void, Void, Void> implements
            DialogInterface.OnCancelListener {

        private ProgressDialog processDialog;

        @Override
        protected void onPreExecute() {
            processDialog = ProgressDialog.show(List.this, "",
                    getString(R.string.loading), true);
            processDialog.setCancelable(true);
        }

        public void onCancel(DialogInterface arg0) {
            // TODO Auto-generated method stub

            if (processDialog.isShowing()) {
                processDialog.dismiss();
            }

        }

        @Override
        protected Void doInBackground(Void... arg0) {
            // TODO Auto-generated method stub

            Jsonfunctions jParser = new Jsonfunctions();
            JSONObject json = jParser.getJSONFromUrl(url);
            try {
                // Getting Array of Contacts
                results = json.getJSONArray(TAG_RESULTS);

                // looping through All Contacts
                for (int i = 0; i < results.length(); i++) {
                    JSONObject c = results.getJSONObject(i);

                    id = c.getString(TAG_ID);
                    name = c.getString(TAG_NAME);
                    adress = c.getString(TAG_ADRRESS);
                    latitude = c.getString(TAG_LATITUDE);
                    latitudeAry.add(c.getString(TAG_LATITUDE).toString());
                    longitude = c.getString(TAG_lONGITUDE);
                    latitudeAry.add(c.getString(TAG_lONGITUDE).toString());
                    distance = c.getString(TAG_DISTANCE);
                    image = c.getString(TAG_IMAGE);
                    phone = c.getString(TAG_TELEPHONE);
                    telphonenumberAry
                            .add(c.getString(TAG_TELEPHONE).toString());
                    NameAry.add(c.getString(TAG_NAME).toString());

                    resourceAry.add(new ResourceClass(point, id, name, adress,
                            distance, latitude, longitude, phone));
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        @Override
        protected void onPostExecute(Void unused) {
            if (processDialog.isShowing()) {
                processDialog.dismiss();
            }
            listView.setAdapter(new ASyncAdapter());
            listView.setDividerHeight(2);
            listView.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> arg0, View arg1,
                        int position, long id) {

                    Intent details = new Intent(List.this, Details.class);
                    details.putExtra("position", position + 1);
                    details.putExtra("name", resourceAry.get(position)
                            .getName());
                    details.putExtra("adress", resourceAry.get(position)
                            .getAdress());
                    details.putExtra("phone", resourceAry.get(position)
                            .getTelephone());
                    details.putExtra("latitudes", latitude);
                    details.putExtra("longitudes", longitude);
                    startActivity(details);

                }
            });
        }
    }

Thanks in advance

  • 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-01T02:57:57+00:00Added an answer on June 1, 2026 at 2:57 am

    I had just finished working on similar kind of requirement(issue faced on is specified in)

    Hence I’m hoping to provide you proper solution that is helpful to you and saves ur time.

    If I’m not wrong you need to populate same ListView with next 20(i.e. 21 – 40) fields obtained in response for server api.

    In that case u need to call server api again and again for that u need an event. Say u add a ‘Next’ button and on its click u retrive next 20 fields(21 – 40).

    Currently in ur code in ‘DoInBackgrd’, you are binding/setting Adapter(ASyncAdapter) each time you need to bind new records/fields to ListView. This is not a good practice, also it at a instance it will not refresh fields of newly assigned adapter in listView.

    Hence you should :

    1. Just retrieve/parse new fileds from JSon and set them in adapter. Adapter will notify your listView about data change and listView will refresh its view.
    2. Considering that ‘ASyncAdapter’ is your custom adapter that implements ArrayAdapter, just add following(change Variable type from Restaurant to as per your requirement) method to it.

      public void reSet(ArrayList<Resturant> resturantsCache) {
                 //This will clear your current fields/records in adpter
         clear();
      
                 //This will new fields/records in adpter from provided resturantsCache ArrayList.
         for (Resturant resturant : resturantsCache) {
              add(resturant);
          }
      }
      

    Hope you will be able to replace variable types in provided method and use it as per you requirements, In case you need more help please provide ASyncAdapter code.

    Thanks.

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

Sidebar

Related Questions

I have this url which is JSON webservice http://ws.geonames.org/weatherJSON?north=90&south=-9.9&east=-22.4&west=55.2 I need to write a
I have this NodeJS app which fetches JSON-type response from a web application and
I have a news feed where items in the feed are created from JSON
I have a JSON feed (which I don't directly control, I have to ask
I'm working on a rake task which imports from a JSON feed into an
I am using Ember.js to create a table from a json feed. I have
Let's say I have a server side script which generates JSON from a simple
Hi all i am trying to setup a json feed. i have been working
I have created a jQuery plugin that grabs a JSON feed (in this case
Good day, I have a photo gallery that pulls from a json feed. 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.