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
Javier Delgado
Courses Plus Student 509 PointsGetting Null trying to read from parcelable data - Stormy App
Hi everyone ! i have enjoy so much following the Weather App course, and i have my app running! even with geolocation, but trying to show the mSummary in the DailyForecastActivity i'm getting on troubles, xD. I'm trying to read mSummary from the parcelable data to show in the bottom textView on the activity, the code explains better than me, xD. I'm doing this when dailyButton onClick:
@OnClick(R.id.dailyButton)
public void startDailyActivity (View view){
Intent intent = new Intent(this, DailyForecastActivity.class);
intent.putExtra(DAILY_FORECAST, mforecast.getDailyForecast());
DailyWeather dailyWeather = new DailyWeather();
intent.putExtra(WEEK_SUMMARY, dailyWeather);
startActivity(intent);
}
As seen, the intent goes to DailyForecastActivity.class, wich is here:
public class DailyForecastActivity extends ListActivity {
private DailyWeather[] 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);
DailyWeather weekSummary = getIntent().getParcelableExtra(MainActivity.WEEK_SUMMARY);
TextView textView = (TextView) findViewById(R.id.weekSummary);
textView.setText("prueba" + weekSummary.getSummary()); //NULL is here!
mDays = Arrays.copyOf(parcelables, parcelables.length, DailyWeather[].class);
DayAdapter adapter = new DayAdapter(this, mDays);
setListAdapter(adapter);
}
}
The DayAdapter.java is only for the ListView, right? I'm taking the correc aproach to show the mSummary ?
Thanks in advance!