Search code examples
androidandroid-listviewlistviewitemonitemclicklistener

How to recognize selected view in onItemClick in Android


I have a list view and each row of it has 3 buttons(Click able Image Views) making different actions if they are clicked.

I have a trouble with it because I don´t know how to recognize if the user click the button for delete or edit the element. I mean, How can I get the View that the user selected?

I tried with the parameters of onItemClick but I´m get stuck in there.

public void onItemClick(AdapterView<?> av, View v, int pos, long id)

Thanks.enter image description here


Solution

  • Try adding tags to your buttons and in onClickListener call view.getTag().