我有一个列表视图,其中包含我所有用户的列表.列表中的每个项目都是一个布局,其中包含一个按钮,用于显示AlertDialog以更改按钮标签的值.如何动态地将单击事件添加到listview适配器生成的按钮?
这是我的适配器:
public class PerfilAdapter extends BaseAdapter {
Context mContext;
LayoutInflater mLayoutInflater;
List<PerfilBean> listaPerfiles = new ArrayList<PerfilBean>();
public Settings01 set=new Settings01();
public PerfilAdapter(Context context,List<PerfilBean> lista) {
mContext = context;
mLayoutInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
listaPerfiles=lista;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return listaPerfiles.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return listaPerfiles.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View …Run Code Online (Sandbox Code Playgroud)