How to avoid setting inline onClickListner in getView()?

Your activitiy has to implement the OnClickListener, and move the implemented method up to the activity level Based on the view parameter of the method you are able to detect from which UI object the event came from (button, textview) As for how to detect for which record/row in a listview. You have to set a custom tag on the buttons and textviews in the getView method, that you will read in the event via getTag this tag can be a custom object too if string is not enough. Probably/recommended way is to be the position in the adapter.

Your activitiy has to implement the OnClickListener, and move the implemented method up to the activity level. Based on the view parameter of the method you are able to detect from which UI object the event came from (button, textview). As for how to detect for which record/row in a listview.

You have to set a custom tag on the buttons and textviews in the getView method, that you will read in the event via getTag this tag can be a custom object too if string is not enough. Probably/recommended way is to be the position in the adapter.

That is what I thought. Unfortunately I'm using setTag for slow adapter. I will rebuild my code and try it out.

– darbat Aug 9 '10 at 18:36.

I am afraid that Pentium10 answer is not correct. If the checkbox is to be clickable and checkable independently from the list item itself, (say it is defined in the list item xml layout), then it will intercept the click event, and the list item (the list's OnItemClickListener) will not receive the click at all. Therefore you must implement the onClickListener in the adapter itself - either in getView(), or have the adapter implement onClickListener - in this case the items must be tagged for the listener to know which item it is operating on.

Yes, you have to set onClickListener on every view (inside row layout) from which you would like to receive callbacks. – darbat Feb 16 at 21:12.

Android - How to avoid setting inline onClickListner in getView() - Stack Overflow.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions