重写BaseAdpterd得到getView这个方法
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
// 获得ViewHolder对象
holder = new ViewHolder();
//position传入你要监听的按钮事件中
holder.Btn=(Button) convertView.findViewById(R.id.btnDownload);
holder.Btn.setOnClickListener(new BtnOnClickListener(position));
}
}
//按钮监听
class BtnOnClickListener implements android.view.View.OnClickListener{
private int position;
public AlterOnClickListener(int pos) {
// TODO Auto-generated constructor stub
position=pos;
}
@Override
public void onClick(View v) {
System.out.println("下载 编号:"+position);
}
}