如何使用onClickListener按钮的方法在一个ListView [英] how to use onClickListener method of Button on a ListView

查看:121
本文介绍了如何使用onClickListener按钮的方法在一个ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的的ListView 包含一个按钮。该按钮的功能是删除按钮。每当用户点击这个按钮,当前的行会被删除。

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.


  • 我该怎么办呢?

  • 如何设置 onClickListener 这个按钮?

  • 我如何能赶上行ID此按钮上?

  • 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?

在此先感谢。

推荐答案

在您的自定义Adapater 类的 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...              
   }
});

这篇关于如何使用onClickListener按钮的方法在一个ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆