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
Steve Hunter
57,712 PointsPopulating the custom list with DayAdapter
Hi Ben Jakuben
I'm having some trouble getting the Daily forecast to appear in the custom list. I just get the id/empty text showing.
I've done some work with the debugger to see if the code fails anywhere obviously, but it doesn't. The app fires up just fine, obtains a location from the GPS and then requests the weather info from forecast.io and updates the display. Lovely!
The buttons at the bottom don't both work as I've not got that far yet, but the ButterKnife @OnClick works fine and takes me to the DailyForecastActivity, as it should.
Inserting breakpoints in here shows that mDays does get populated with the array of weather data, as required. So, on hitting the line,
DayAdapter adapter = new DayAdapter(this, mDays);
all the info is in place, you'd think. But, no, I get nothing on the activity when it starts, just the 'no data to display' string. A breakpoint in the DayAdapter class never gets reached but I guess I'm running an instance of it behind the scenes.
I don't really understand how the getView() method in there would ever get called as we just instantiate an instance of DayAdapter and then do nothing else with the local instance, adapter.
Have I missed something?
My Github repo is here if you want to see my code:
https://github.com/OnlySteveH/Stormy2
Any help or pointers would be much appreciated!
Steve.
2 Answers
Steve Hunter
57,712 PointsAdding the obvious line, setListAdapter(adapter); might help.
Apologies ... as you were - standard user error ...
Steve.
Steve Hunter
57,712 PointsYes, I did, no thanks to me!!
Great course - really useful and has given me ideas to try more things for that app.
Thanks, Ben!
Steve.
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherGlad you got it working! :)