what is the difference between onClickListener and onItemClickListener in Android ListViews ? And what are the different implementations of these ?
In Android, the OnClickListener() interface has an onClick(View v) method that is called when the view (component) is clicked. The code for a component's functionality is written inside this method, and the listener is set using the setOnClickListener() method.
OnItemClickListener is an interface and interface has a property that the class which implements it must implement its unimplemented method(s) (because interface contains declaration of methods not implementation).
ListView has an Item Click listener for each row of the listview but the onClickListener is for the whole listview no matter which ever row you click the onClick and onItemClickListener is called but the values that come with each method are different.
OnItemClickListener you can use for lets say going to a particular activity when a particular row is touched.
OnClickListener you can check if the listview has received a touch by the user so do you want to refresh the list? or change the scrollbar's view or do something with the listview as a whole unit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With