Jeff Axelrod
Jeff Axelrod

Reputation: 28198

What is the impact of using onClick within each item view vs. onItemClick in ListView?

I wrote a ListView to select a single item from a list. To achieve what I feel is a better separation of concerns in my ListView implementation, I am setting the onClickListener on each row's item view. Is there any functional difference between doing this and using the ListView's onItemClick?

I'm not terribly familiar with non-touchscreen android device interfaces and after watching the Google ListView video, am wondering if my technique may malfunction on other devices.

Is there any reason not to register onClick on each item's view?

Upvotes: 0

Views: 313

Answers (1)

Gopal
Gopal

Reputation: 1719

The benefit you get from onItemClick is the paramters passed through function call specially position as a parameter. On OnClick its hard to determine which row has been clicked.

And onClick need to be registered with each row (view/layout) of ListView, while onItemClick need to be registered only once by calling setOnItemClickListener on ListView object.

Upvotes: 1

Related Questions