Stephane Maarek
Stephane Maarek

Reputation: 5352

Android: OnClick Listener in an adapter or outside of it?

Performance wise, is it the same to place an onclick listener in a getView() call of an adapter or place the onclick listener outside on a listview that contains the adapter?

My underlying thought is to reduce code if I use the same adapter in two different places. But I need to make sure the performance wouldn't be affected!

Upvotes: 1

Views: 440

Answers (1)

Ifrit
Ifrit

Reputation: 6821

The performance difference would be so negligible, I wouldn't even worry about it. Instead opting for whatever seems to be fit for your design approach. If you want to reduce code duplication, putting it in the getView() works just fine.

Upvotes: 1

Related Questions