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

onListItemClick not being called

I have tried everything and when I put a log in the onListItemClick it doesn't log anything. This leads me to believe that it isn't being called. I even downloaded the project and copy pasted the code for the onListItemClick. Nothing has worked so far.

public class DailyForecastActivity extends ListActivity {

private Day[] mDays;
@Bind(R.id.locationTextLabel) TextView mTimeLabel;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_daily_forecast);

    ButterKnife.bind(this);
    Intent intent = getIntent();
    Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.DAILY_FORECAST);
    mDays = Arrays.copyOf(parcelables, parcelables.length, Day[].class);

    mTimeLabel.setText(mDays[0].getTimeZone());
    DayAdapter adapter = new DayAdapter(this, mDays);
    setListAdapter(adapter);
}

@Override

protected void onListItemClick(ListView l, View v, int position, long id) {

    super.onListItemClick(l, v, position, id);

    String dayOfTheWeek = mDays[position].getDayOfTheWeek();

    String conditions = mDays[position].getSummary();

    String highTemp = mDays[position].getTemperatureMax() + "";

    String message = String.format("On %s the high will be %s and it will be %s",

            dayOfTheWeek,
            highTemp,
            conditions);

    Toast.makeText(this, message, Toast.LENGTH_LONG).show();

}

}