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) Standard ListViews Displaying List Data (or None At All)

Christopher Shaw
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 Points

@OnClick & Butterknife 7

Any one using Butterknife 7, this is how I got the @OnClick listener to work. A better solution would be to use an older version of Butterknife (Ver 6) to match the video. I hope this is helpful.

@OnClick (R.id.dailyButton) void OnClick() {
        Intent intent = new Intent(this, DailyForecastActivity.class);
        startActivity(intent);
    }

3 Answers

John McDonald
John McDonald
13,958 Points

Hey Christopher, I am using version 7.0.1 of ButterKnife and I used

@OnClick (R.id.dailyButton)
public void startDailyActivity(View view) {
    Intent intent = new Intent(this, DailyForecastActivity.class);
    startActivity(intent);
}

and it worked fine.

Rami Awar
Rami Awar
5,435 Points

This didn't work for me I'm still crashing on clicking the button :( EDIT: Nevermind it worked. Turns out I had no xml file created due to some UNDO bug in android studio.

pranav kakkad
pranav kakkad
755 Points

I have tried both ways but still my app is not responding to the button