我有一个RecyclerView。数据来自服务器。列表项视图包含:
one TextView
one EditText
one Button
我有10个列表项。单击按钮时,数据将发送到服务器,成功提交后,按钮可见性将设置为View.INVISIBLE
。问题是,当提交按钮(数据将发送并且按钮可见性设置为INvisble)并向下和向上滚动时,提交的列表保持不变,即可见性变为可见。
绑定视图持有者
@Override
public void onBindViewHolder(final ViewHolder1 holder, final int position) {
final Ardlist_item listitem = listitems.get(position);
holder.textitemname.setText(listitem.getItemname());
holder.liftqty.setText(listitem.getQty());
holder.rcqty.setText(listitem.getQty());
holder.b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.b1.setVisibility(View.INVISIBLE);
holder.rcqty.setEnabled(false);
Toast.makeText(context, "clicled" + position, Toast.LENGTH_LONG).show();
}
});
}
获得职位
@Override
public int getItemCount() {
return listitems.size();
}
public class ViewHolder1 extends RecyclerView.ViewHolder {
public TextView liftqty;
public Button b1;
public EditText rcqty;
public ViewHolder1(View itemView) {
super(itemView);
textitemname = (TextView) itemView.findViewById(R.id.item_name);
liftqty = (TextView) itemView.findViewById(R.id.lifted_qty);
b1 = (Button) itemView.findViewById(R.id.receive_btn);
rcqty = (EditText) itemView.findViewById(R.id.received_qty);
}
}