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 trialSlava Fleer
6,086 PointsI still see the empty list text when pressing 7 days button
I still in searching for my mistakes, but maybe someone have in mind quick solution for checking =) I really would be happy for help.
Any way I tried to post Log.v in DayAdapter.java for debugging and it doesn't work. What wrong about same way that we did in MainActivity ?
public class DayAdapter extends BaseAdapter {
public static final String TAG = DayAdapter.class.getSimpleName();
Log.v(TAG,"Reached the point in adapter");
private Context mContext;
private Day[] mDays;
I have mistake on v in Log.v . It's saying cannot resolve symbol v.
What I understand right now that my adapter is the problem, cause before it worked with simple list of days of a week worked, and in debugging I do see the Parcel data transferred to new activity.
Slava Fleer
6,086 PointsSomething new that I just found about Logs, it must be in method - didn't know about it. I'm going to debug each centimeter of the code with logs right now...
Slava Fleer
6,086 Pointsmy DailyForecastActivity code is running the DayAdapter, at least the constructor. I tried to check the implemented methods in DayAdapter, but it is not show me Log in it. So its not running. What I must check next ? I can't continue the course right now =(
Thanks again for any help.
package com.slava.whetherapp.ui;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import com.slava.whetherapp.R;
import com.slava.whetherapp.adapters.DayAdapter;
import com.slava.whetherapp.weather.Day;
import java.util.Arrays;
public class DailyForecastActivity extends ListActivity {
private Day[] mDays;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_daily_forecast);
Intent intent = getIntent();
Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.DAILY_FORECAST);
mDays = Arrays.copyOf(parcelables, parcelables.length, Day[].class);
DayAdapter adapter = new DayAdapter(this, mDays);
}
}
6 Answers
Adam Sommer
62,470 PointsNot 100% sure, but I think you have to move the Log.v call into a method. Maybe try moving the Log.v call into the getView() method? Might also try Log.i or Log.d and see if that gives you some output.
Slava Fleer
6,086 Pointsthanks. yes. you are right with a log. It must be in method. Unfortunately logs didn't help me with my main problem =(
Adam Sommer
62,470 PointsOh right, in the DailyForecastActivity onCreate() method after setting the adapter are you applying it to the activity with
this.setAdapter(adapter);
Might give that a try and see if it populates the ListView. I think that's your main problem right?
Slava Fleer
6,086 PointsYes. I just found it myself. In the video there is no any moment that returning this line =) Thank you. And Ben, you need to add in teacher notes something about it =)
Ben Jakuben
Treehouse TeacherGlad you got past the Log trouble! Are you still having any other trouble?
Slava Fleer
6,086 Pointsto Ben: Yes. Please see here https://teamtreehouse.com/forum/fatal-exception-main
Stephen Little
8,312 PointsDid this get updated or did I just miss it when I went through it?
Angel Viera
3,293 PointsThis was also happening to me. They must have accidentally cut the part where Ben added the call to "setListAdapter(adapter)
" at the end of the onCreate()
method of DailyForecastActivity
. It eventually appears in the video, but they never actually show him write it, so it's easy to miss.
This is what the onCreate method should look like:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_daily_forecast);
Intent intent = getIntent();
Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.DAILY_FORECAST);
mDays = Arrays.copyOf(parcelables, parcelables.length, Day[].class);
DayAdapter adapter = new DayAdapter(this, mDays);
setListAdapter(adapter); // <-- THIS LINE
}
Ben Jakuben
Treehouse TeacherDoh! Great catch. I'm so sorry about that! I didn't catch that mistake while reviewing this course. I'll make sure we update the video!
Dave Bond
1,180 PointsBen Jakuben Hey Ben, the video still is't updated. Just an FYI.
Derese Getachew
Courses Plus Student 1,840 PointsBen Jakuben Please add it to teachers note
rtrind
6,358 PointsYES! One more vote for a teachers note for this line missing...
Greg Austin
10,890 PointsGlad it wasn't just me lol. Looked through my code and Android Studio was telling me my "Variable 'adapter' is never used" (you know, the grayed out text and when you hover over it...). Thought, Hey, now, if the adapter is never used that would certainly be the issue here. Took a closer look at the code on the video and sure enough there was the set method. Checked my notes, no mention, checked the vids, no mention. Finally checked the forums just to make sure I wasn't crazy lol.
Just thought I'd share a good tip: go through your variables and such to make sure everything you need has been set and Android Studio makes this real easy by graying out unused variables. Proud of myself for catching that so quickly :)
taubin
8,705 PointsUnfortunately, this still hasn't been corrected or added to the teachers notes. Luckily I was able to find it here, but it's pretty buried now. Any chance of this being updated?
Slava Fleer
6,086 PointsSlava Fleer
6,086 Pointsmy DayAdapter.java code