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

Jason Thorn
Jason Thorn
2,611 Points

Can I pick your brain?

Hi All

I'm currently trying my hand at building a weather app (Inspired by Ben). At the moment I'm looking putting together some sort of Horizontal view to show a brief summary for each day of the week e.g. Image on top with with two TextView underneath showing High and Low temperatures.

I figure that a ListView would be my best bet thanks to the magic of adapters - but it turns out that the SDK doesn't come equipped with a Horizontal ListView :(. So I've turned to a HorizontalScrollView containing a RelativeLayout inside. However if I continue down this path (based on my limited knowledge) I cannot use an adapter to fill the ScrollView - Instead I'd have to update all the images and TextViews line by line, which doesn't seem very particle.

Has anyone else had a similar issue?

I've found the TwoWayView library on GitHub but I - 1, Can't figure out how to add it into Android Studio & b. Can't get it to work in Eclipse either :)

I'd really appreciate any help and advice you'd have to offer.

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

I used a ScrollView to do a handful of items horizontally before, but never a horizontal ListView with more items. This is a great question without a satisfactory answer (at least not with a quick search). This library looks promising, though: https://github.com/sephiroth74/HorizontalVariableListView

Jason Thorn
Jason Thorn
2,611 Points

Tell me about it! :) I almost went mad trying to find the answer to my question.

I did see a reference to that library on my google travels, the problem I had though - like with the TwoWayView lib, is that I can't figure out how to get it into Android Studio. Each time I try I always end up with some sort of gradle error... I think I need to re-watch the videos you made on 'An Overview of Android Studio'. I'm pretty sure you adding/importing libraries.

If I get stuck I'll put my hand up and ask for help :)

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Sounds like a plan! If you update AS to the latest you should be able to add the following line in the build.gradle file in your app module. This feature of Gradle is awesome; it automatically includes the version that you specify without any additional work. I'll try it out myself if I have a chance, too.

compile 'it.sephiroth.android.library.horizontallistview:library:+'

Your dependencies section should look something like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'it.sephiroth.android.library.horizontallistview:library:+'
}

As for using it, I see the library includes a demo project. Hopefully there's enough there to figure out how to include it in your own project.