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 Build a Blog Reader Android App Adapting Data for Display in a List Adding Secondary Data with a SimpleAdapter

Tyler Cassity
Tyler Cassity
4,873 Points

Adding Secondary Data With a SimpleAdapter - Author variable labeled "redundant, or not being used"

After following the video and getting to the end, when i run my app it isnt showing the secondary author info. In my code "KEY_AUTHOR" is grey everywhere it is used and marked as unused. I keep looking at my code and i cant find anything i have done wrong. Im thinking it might be the "simple_list_item_2" or maybe the fact im using android studio instead of eclipse? Anyone have any ideas?

1 Answer

Within the handleBlogResponse method...

String[] keys = { KEY_TITLE, KEY_AUTHOR };
                int[] ids = { android.R.id.text1, android.R.id.text2 };
                SimpleAdapter adapter = new SimpleAdapter(this, blogPosts,
                        android.R.layout.simple_list_item_2, keys, ids);

                setListAdapter(adapter);

This is the propper way to set texts 1 and 2 of the simple_list_item_2 adapter. :) Your IDE should have nothing to do with the error. I completed the project in Android Studio as well, and it worked fine. Though, if you figure out which section the error is in (try using breaks or debug mode?), it would help to see what you have typed up. :)