Butterknife: @OnItemClick with View and position

Created on 7 May 2014  路  2Comments  路  Source: JakeWharton/butterknife

I'm able to get this library working properly, and it's awesome.

However, had a question regarding ListView's.

Right now i'm doing this:

@OnItemClick(R.id.listView)
public void onItemClick(int position) {
}

Is it possible for the function to take pass in the ListView as well? I want to be able to consolidate the onItemClick into one function in case there is more than one ListView in the view.

Most helpful comment

I figured it out. No need, I'll answer what I found:

public void onItemClick(AdapterView<?> parent, int position) {
}

All 2 comments

I figured it out. No need, I'll answer what I found:

public void onItemClick(AdapterView<?> parent, int position) {
}

Yep. You should also just be able use a ListView as an argument as well. It will do the cast.

Was this page helpful?
0 / 5 - 0 ratings