how to use onClickListener method of Button on a ListView

android, android-listview, button, onclicklistener

Solution

In your Custom Adapater class's `getView()`

buttonDelete.setOnClickListener(new OnClickListener()
{
  @Override
  public void onClick(View v)
   {
     //  Use position parameter of your getView() in this method it will current position of Clicked row button
    // code for current Row deleted...              
   }
});

Problem

I have a custom `ListView` which contains a `Button`. The function of this button is Delete button. Whenever user click to this button, the current Row will be deleted. - How can I do it? - How can I set `onClickListener` for this button? - How can I catch the row Id which this button is on? Thanks in advance.

Original source