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 Android Lists and Adapters (2015) Lists with RecyclerViews Making Hour Parcelable

Chris Vukin
Chris Vukin
17,787 Points

hourly activity file errors

I'm having some difficulty with errors in my HourlyForecastActivity file.

''' java package com.evermedresearch.stormy.ui;

import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.os.Parcelable; import android.support.v7.app.ActionBarActivity;

import com.evermedresearch.stormy.R; import com.evermedresearch.stormy.weather.Hour;

import java.util.Arrays;

public class HourlyForecastActivity extends ActionBarActivity {

private Hour[] mHours;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hourly_forecast);
}

Intent intent = getIntent();
Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.HOURLY_FORECAST);
mHours = Arrays.copyOf(parcelables, parcelables.length, Hour[].class);

} '''

It's saying mHours is an unknown class, cannot resolve symbol 'copyOf', parcelables is an unknown class, cannot resolve symbol 'length' and after Hour[]. identifier expected unexpected token.

Any thoughts would be great

1 Answer

Your code needs to be within the curly braces of the onCreate method. Basically, move the closing curly brace after

setContentView(R.layout.activity_hourly_forecast);

so its below

mHours = Arrays.copyOf(parcelables, parcelables.length, Hour[].class);

Chris Vukin
Chris Vukin
17,787 Points

Thanks Ozhan! It's always the little things :)