ListView使用SimpleAdapter时给item中的Button添加点击事件
cardAdapter = new SimpleAdapter(this, cardList, R.layout.item_my_card_unuse, cardFromUnuse, cardToUnuse){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int p=position;
final View view=super.getView(position, convertView, parent);
Button useBtn=(Button)view.findViewById(R.id.my_card_use_btn);
useBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MyCardResourcesListActivity.this,"已下發",Toast.LENGTH_SHORT).show();
}
});
return view;
}
};