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

Blog Reader

I'm at the step where we populate the array with the json data, but the data does not display in the emulator, what i get is: " No item to display.

public void updateList() {
      if (mBlogData == null){

    }
    else{
        try {
            JSONArray jsonPosts = mBlogData.getJSONArray("posts");
            mBlogPostTitles = new String[jsonPosts.length()];
            for(int i = 0; i < jsonPosts.length(); i++){
                JSONObject post = jsonPosts.getJSONObject(i);
                String title = post.getString("title");
                title = Html.fromHtml(title).toString();
                mBlogPostTitles[i] = title;
            }
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, mBlogPostTitles);
            setListAdapter(adapter);

        } catch (JSONException e) {
            Log.e(TAG, "Exception caught!", e);
        }
    }

can someone help please

1 Answer

NVM it works