Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Pedro Duarte
Pedro Duarte
300 Points

How to display ArrayJson inside TableLayout?

When i show the values is my tableLayout only display 0 0 0 0 0 0 0 0 for the Values position, points , playedGames, and so on..... also i cant get all array values only the first line. Appreciate yours thoughts.

JsonApi "http://api.football-data.org/v1/competitions/444/leagueTable"

private Liga[] getLigaForecast(String jsonData) throws JSONException { JSONObject lertabela = new JSONObject(jsonData); JSONArray standing = lertabela.getJSONArray("standing");

    Liga[] ligas = new Liga[standing.length()];

    for (int i = 0 ; i < standing.length(); i++){
        JSONObject jsonLiga =  standing.getJSONObject(i);
        Liga liga = new Liga();

        liga.setPosicao(jsonLiga.getInt("position"));
        liga.setPontos(jsonLiga.getInt("points"));
        liga.setJogos(jsonLiga.getInt("playedGames"));
        liga.setVitorias(jsonLiga.getInt("wins"));
        liga.setEmpates(jsonLiga.getInt("draws"));
        liga.setDerrotas(jsonLiga.getInt("losses"));
        liga.setgolsPros(jsonLiga.getInt("goals"));
        liga.setgolsContra(jsonLiga.getInt("goalsAgainst"));
        liga.setsaldoGols(jsonLiga.getInt("goalDifference"));
        liga.setTimeNome(jsonLiga.getString("teamName"));


        ligas[i] =  liga;

    }

    return ligas;

}