基本上我需要的是更新你点击按钮的listview项的值。
@Override
public View getView(int position, View convertView, final ViewGroup parent) {
ViewHolder holder = null;
RowItem rowItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.lista_validacion_multiple, null);
holder = new ViewHolder();
/*holder.row1 = (TableRow)convertView.findViewById(R.id.tableRow2);
holder.row2 = (TableRow)convertView.findViewById(R.id.tableRow3);*/
holder.txtNombre = (TextView)convertView.findViewById(R.id.txtNombre);
holder.txtAsiento = (TextView)convertView.findViewById(R.id.txtAsiento);
holder.txtTicket = (TextView)convertView.findViewById(R.id.txtTicket);
holder.txtNumero = (TextView)convertView.findViewById(R.id.txtNumero);
holder.btn = (Button)convertView.findViewById(R.id.button1);
//holder.imageView = (ImageView)convertView.findViewById(R.id.icon1);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
holder.txtNombre.setText("Nombre :"+rowItem.getNombre());
holder.txtTicket.setText("Ticket :"+rowItem.getTicket());
if (!rowItem.getAsiento().equals("") && !rowItem.getAsiento().equals("null") && rowItem.getAsiento() != null) {
holder.txtAsiento.setText("Asiento :"+rowItem.getAsiento());
}
if (!rowItem.getNumero().equals("") && !rowItem.getNumero().equals("null") && rowItem.getNumero() != null) {
holder.txtNumero.setText("Número :"+rowItem.getNumero());
}
if(rowItem.getValidado()==1){
holder.btn.setBackgroundResource(R.drawable.icon_big_alert);
holder.btn.setText("");
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int)LayoutParams.WRAP_CONTENT, (int)LayoutParams.WRAP_CONTENT);
params.width = 50;
params.height = 50;
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
holder.btn.setLayoutParams(params);
}else{
holder.btn.setTag(position);
holder.btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position=(Integer)v.getTag();
RowItem item_click = getItem(position);
Connection cn = new Connection();
SessionManager manager = new SessionManager();
if(cn.isNetworkAvailable(parent.getContext())){
}else{
BaseDeDatos nueva = new BaseDeDatos();
}
}
});
}
return convertView;
}
我考虑过调用holder.btn
,但这不起作用,因为它不在同一个上下文中,有一些方法可以编辑这个项目吗?
答案 0 :(得分:0)
试试这个
int position= Integer.parseInt(v.getTag());
希望这项工作