我遇到了一个适配器的问题,该接收器从付款状态接收信息arraylist,其具有“AT”状态,当值得绘制特定颜色时,android绘制该状态和其他状态那个在“AT” 没有任何疑问。我用equals验证它,但似乎它是android的malograra并验证不是“AT”的其他人。
public class PlanPagosCreditoAdapter extends ArrayAdapter<beanDatosPlanPagosCredito> {
public List<beanDatosPlanPagosCredito> list;
public PlanPagosCreditoAdapter(Context context, List<beanDatosPlanPagosCredito> objects) {
super(context, 0, objects);
list = objects;
}
@Override
public beanDatosPlanPagosCredito getItem(int position) {
return list.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Obtener inflater.
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewHolder holder;
if (null == convertView) {
convertView = inflater.inflate(
R.layout.lista_detalle_creditos,
parent,
false);
holder = new ViewHolder();
holder.fecha_cuota = (TextView) convertView.findViewById(R.id.fecha_cuota);
holder.num_cuota = (TextView) convertView.findViewById(R.id.num_cuota);
holder.deuda = (TextView) convertView.findViewById(R.id.deuda);
convertView.setTag(holder);
}else{
holder= (ViewHolder)convertView.getTag();
}
beanDatosPlanPagosCredito credito = getItem(position);
holder.fecha_cuota.setText(credito.getFechaCuota());
holder.num_cuota.setText(credito.getNumeroCuota());
DecimalFormat precision = new DecimalFormat("0.00");
// subtotal.setText(precision.format(deuda));
holder.deuda.setText(precision.format(credito.getDeuda()));
if(credito.getEstado().equals("AT")){
holder.deuda.setTextColor(Color.RED);
}
return convertView;
}
static class ViewHolder {
TextView fecha_cuota;
TextView num_cuota;
TextView deuda;
}
}
答案 0 :(得分:0)
问题在于您的观点正在被回收,而且它们仍然保持红色。添加一个重置文本颜色的else子句:
if(credito.getEstado().equals("AT")){
holder.deuda.setTextColor(Color.RED);
} else {
holder.deuda.setTextColor(Color.BLACK);
}