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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:16:32+00:00 2026-06-18T19:16:32+00:00

Hello, I’m having a hard time understanding how to do what I want with

  • 0

Hello, I’m having a hard time understanding how to do what I want with my JSON parser. I’m currently parsing the data located at http://api.pathofexile.com/leagues?type=all to pull out the league ids (currently they are “Default”, “Hardcore”, “Feb 12 Solo HC Race”, etc.) My parser currently puts these ids into a listview.

The problem I’m having is that these ids will change over time. They also have their own JSON urls that I need to parse based on the league id. For example, if the league id is “Default” I need to take that id and put it into the url:

“api.pathofexile.com/leagues/”+ id +”?ladder=1&ladderOffset=1&ladderLimit=2″ to get http://api.pathofexile.com/leagues/Default?ladder=1&ladderOffset=1&ladderLimit=2

Basically, I want to be able to click the id in the listview and have it update the url and parse the new data into a separate list.

Here is what I have for my JSON parser:

public class Leagues extends ListActivity {
    public static String url = "http://api.pathofexile.com/leagues?type=all";

    private static final String TAG_ID = "id";
    static InputStream is = null;
    static JSONObject jObj = null;
    static String json = "";

    JSONArray leagues = null;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.list_item);
        new GetJSONTask().execute("");
    }

    protected class GetJSONTask extends AsyncTask<String, Integer, ArrayList<HashMap<String, String>>> {
        protected ArrayList<HashMap<String, String>> leaguesList;

        private final ProgressDialog dialog = new ProgressDialog(Leagues.this);

        // onPreExecute method
        protected void onPreExecute() {
            this.dialog.setMessage("Loading, Please Wait..");
            this.dialog.setCancelable(false);
            this.dialog.show();
        }

        // doInBackground method
        @Override
        protected ArrayList<HashMap<String, String>> doInBackground(String... params) {
            leaguesList = new ArrayList<HashMap<String, String>>();

            // defaultHttpClient
            try {
                DefaultHttpClient httpClient = new DefaultHttpClient();
                HttpGet HttpGet = new HttpGet(url);

                HttpResponse httpResponse = httpClient.execute(HttpGet);
                json = EntityUtils.toString(httpResponse.getEntity());

                // getting array of entries
                JSONArray leagues = new JSONArray(json);

                // looping through entries
                for (int i = 0; i < leagues.length(); i++) {
                    JSONObject league = leagues.getJSONObject(i);

                    String id = league.getString(TAG_ID);

                    // creating new HashMap
                    HashMap<String, String> map = new HashMap<String, String>();

                    // adding each child node to HashMap key => value
                    map.put(TAG_ID, id);
                    //map.put(TAG_EVENT, event);

                    // adding HashList to ArrayList
                    leaguesList.add(map);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return leaguesList;
        }

        // onPostExecute method
        protected void onPostExecute(ArrayList<HashMap<String, String>> result) {
            ListAdapter adapter = new SimpleAdapter(getApplicationContext(), leaguesList, R.layout.league, new String[] { TAG_ID }, new int[] { R.id.id });
            // selecting single ListView item
            ListView lv = getListView();
            lv.setAdapter(adapter);

            if (this.dialog.isShowing()) {
                this.dialog.dismiss();
            }

        }
    }

}

I’m pretty lost at this point. Is what I’m trying to do even possible with how I have the parser set up now? Can anybody point me in the right direction?

Thanks.

EDIT for further clarification:

Right now my parser will put the league ids into a ListView from the url “api.pathofexile.com/leagues?type=all” like below:

  1. Default
  2. Hardcore
  3. Feb 12 Solo HC Race

(These items will change over time)

I want to be able to click on “Default,” which will change the url to “api.pathofexile.com/leagues/Default?ladder=1&ladderOffset=1&ladderLimit=2” and parse it into a new ListView.

UPDATE:
Using the project provided by Darwind, I changed it around (using some of my other code) to show the JSON data that I wanted after clicking on the league id.

public class LeagueView extends ListActivity {
    //private TextView leagueId, leagueDescription;
    private static final String TAG_LADDER = "ladder";
    private static final String TAG_ENTRIES = "entries";
    private static final String TAG_ONLINE = "online";
    private static final String TAG_RANK = "rank";
    private static final String TAG_CHARACTER = "character";
    private static final String TAG_CHARNAME = "name";
    private static final String TAG_LEVEL = "level";
    private static final String TAG_CLASS = "class";
    private static final String TAG_EXPERIENCE = "experience";
    private static final String TAG_ACCOUNT = "account";
    private static final String TAG_ACCNAME = "name";
    private static final String TAG_ACCNAME2 = "name2";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.league_layout);

    //leagueId = (TextView) findViewById(R.id.leagueId);
    //leagueDescription = (TextView) findViewById(R.id.leagueDescription);

    String urlToJson = getIntent().getExtras().getString("leagueUrl");

    if (urlToJson == null) {
        Toast.makeText(this, "Url was null!", Toast.LENGTH_LONG).show();
    } else {
        new LeagueTask().execute(urlToJson.replaceAll(" ", "%20"));
    }
}

protected class LeagueTask extends AsyncTask<String, Integer, League> {
    private final ProgressDialog dialog = new ProgressDialog(LeagueView.this);
    protected ArrayList<HashMap<String, String>> entriesList;

    // onPreExecute method
    protected void onPreExecute() {
        this.dialog.setMessage("Retrieving Ladder Information...");
        this.dialog.setCancelable(false);
        this.dialog.show();
    }

    // doInBackground method
    @Override
    protected League doInBackground(String... params) {
        League aLeague = new League();
        entriesList = new ArrayList<HashMap<String, String>>();

        // defaultHttpClient
        try {
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet HttpGet = new HttpGet(params[0]);

            HttpResponse httpResponse = httpClient.execute(HttpGet);
            String json = EntityUtils.toString(httpResponse.getEntity());

            // Getting a JSONObject filled.
            JSONObject leagueObject = new JSONObject(json);

            //String id = leagueObject.getString("id");
            //String description = leagueObject.getString("description");

            JSONObject ladder = leagueObject.getJSONObject(TAG_LADDER);
            JSONArray entries = ladder.getJSONArray(TAG_ENTRIES);

            // looping through entries
            for (int i = 0; i < entries.length(); i++) {
                JSONObject ent = entries.getJSONObject(i);

                // storing each JSON item in a variable
                String online = ent.getString(TAG_ONLINE);
                if (online == "false")
                    online = "Offline";
                else online = "Online";
                String rank = ent.getString(TAG_RANK);

                // pull out character object
                JSONObject character = ent.getJSONObject(TAG_CHARACTER);
                String chName = character.getString(TAG_CHARNAME);
                String lvl = character.getString(TAG_LEVEL);
                String cl = character.getString(TAG_CLASS);
                String xp = character.getString(TAG_EXPERIENCE);

                // pull out account object
                JSONObject account = ent.getJSONObject(TAG_ACCOUNT);
                String accName = account.getString(TAG_ACCNAME);

                // creating new HashMap
                HashMap<String, String> map = new HashMap<String, String>();

                // adding each child node to HashMap key => value
                map.put(TAG_ONLINE, online);
                map.put(TAG_CHARNAME, chName);
                map.put(TAG_ACCNAME2, accName);
                map.put(TAG_RANK, rank);
                map.put(TAG_LEVEL, lvl);
                map.put(TAG_EXPERIENCE, xp);
                map.put(TAG_CLASS, cl);

                entriesList.add(map);
            }

            // creating a league to display
            aLeague = new League();
            //aLeague.setLeagueId(id);
            //aLeague.setDescription(description);

        } catch (JSONException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return aLeague;
    }

    // onPostExecute method
    protected void onPostExecute(League result) {
        //leagueId.setText(result.getLeagueId());
        //leagueDescription.setText(result.getDescription());

        ListAdapter adapter = new SimpleAdapter(getApplicationContext(), entriesList, R.layout.league_layout, new String[] { TAG_RANK, TAG_CHARNAME, TAG_LEVEL, TAG_EXPERIENCE, TAG_CLASS }, new int[] { R.id.rank, R.id.chName, R.id.lvl, R.id.experience, R.id.cl });
        // selecting single ListView item
        ListView lv = getListView();
        lv.setAdapter(adapter);

        if (this.dialog.isShowing()) {
            this.dialog.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-18T19:16:33+00:00Added an answer on June 18, 2026 at 7:16 pm

    Ok so, basically as vsnyc pointed out your title is probably a bit misleading.

    The way I see it, is this:

    1. Get a list of all leagues from parsing a JSON Array
    2. Be able to click a league in the list and get a view supplying info about the selected league, by parsing a JSON Object.

    I basically went and kanged all your code and changed it a bit. For instance I mentioned in a comment, that you should use a class to represent every league and then override the toString method for this new kind of object, so that this class could be used directly in your ListView.

    As the first url you’re using: http://api.pathofexile.com/leagues?type=all is returning a JSON Array and not a single object and the objects inside this array is different from the data returned when selecting a specific league, I wouldn’t recommend to use the same AsyncTask for getting both the list of leagues and a single league.

    Instead after you’ve populated the first ListView with leagues, I would create a second view, that is populated by getting data from a specific league.

    To get to the second view representing one league, you need to implement the OnItemClickListener for the ListView of the first view. In the OnItemClickListener you will get the selected leagues name and pass it to the next view which in turn will contact the server and get the JSON object representing the given league and parse the data.

    I’ve created a small project as this was quite a lot of code to add to the answer and it would take me more time to remove all unnecessary code, than just to give you a full working project. 😉

    Here’s the project in a zip file:

    https://dl.dropbox.com/u/27724371/AndroidListViews.zip

    Let me know if this wasn’t what you were looking for.

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

Sidebar

Related Questions

Hello again stackoverflow! So i build this script: <?php $xmlurl = 'http://api.ipinfodb.com/v2/ip_query.php?key=apikey&ip=127.0.0.100&timezone=false'; $xml =
Hello, I want to put custom status bar in notification window of iphone. is
Hello! I've been programming for a long time but just started developing for android,
Hello all I am working on javascript jquery and svg.I want to ask a
hello evrey body i have try really hard to write a file to android
Hello everyone and thanks for your help! I currently have this program that renames
Hello I want to collect output of following command into some variable.How can I
Hello i want to make something on classes i want to do a super
Hello all and thanks for your time reading this. I need to verify certificates
hello i'm building a wpf app with data grids, the pattern is model view

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.