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 App Alternative to HashMap ArrayList

I feel dirty making an ArrayList of HashMaps so I was brainstorming some alternatives and would love some input on my ideas so far. If I'm wrong and ArrayList of HashMaps is the way to go convince me :)

Would it be easier to just make a BlogPost Object that takes a JSONObject as the constructor? Then we would have our ArrayList be of BlogPost objects. If we wanted to change something like include the ID of the post for example we would simply add the variable in the BlogPost object and change the code in the constructor of it. This would make the code in MainListActivity look a little cleaner I think. Any thoughts? :)

1 Answer

Welp, watching more into the video answered this for me. I guess I better get used to ArrayList Hashmaps :*(

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Haha. Writing a custom adapter can be a pain the first time, but once you have some working code it's easy to build on it or do it again. This will definitely be featured somewhere in either an upcoming project or as a standalone Quick Tip.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Also, forgot to say that I do like your idea better! Having a simple list of custom objects is often the way to go. It's just that writing the custom adapter seemed harder, so I went with the supplied adapter. :)