テキストビューで固定タイトルinvno日付などで詳細を表示するつもりです。以下はリストビューで、顧客アダプターで表示され、行の最後に顧客アダプターで異なる色の合計が表示されます
しかし、2回3回スクロールすると、このような問題が発生します
これは私のcustomeAdpterです
public class CustomAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater=null;
private RelativeLayout relativeCel;
private ArrayList<String> listidA=new ArrayList<String>();
private ArrayList<String> listDateA=new ArrayList<String>();
private ArrayList<String> lisTotalAMTA=new ArrayList<String>();
private ArrayList<String> listPaymenIdA=new ArrayList<String>();
private ArrayList<String> listPaymenNameA=new ArrayList<String>();
private Float total=0.0f;
/**
*
* @param a
* @param listid
* @param listDate
* @param lisTotalAMT
* @param listPaymenId
* @param listPaymenName
*/
public CustomAdapter(Activity a,ArrayList<String>listid,ArrayList<String>listDate,ArrayList<String>lisTotalAMT,ArrayList<String>listPaymenId,ArrayList<String>listPaymenName) {
inflater = (LayoutInflater)a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.activity=a;
this.listidA=listid;
this.listDateA=listDate;
this.lisTotalAMTA=lisTotalAMT;
this.listPaymenIdA=listPaymenId;
this.listPaymenNameA=listPaymenName;
total=0.0f;
for(int i=0;i<listidA.size();i++)
total=total+(Float.parseFloat(""+lisTotalAMTA.get(i)));
}
public int getCount() {
return listidA.size()+1;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public class ViewHolder{
TextView txtInvoiceNo,txtDate,txtPaymentMode ,txtPamentAmount;
}
@SuppressLint("NewApi")
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
AppLog.logString(TAG+"if Null: "+position);
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.item_sales_report, null);
holder = new ViewHolder();
holder.txtInvoiceNo = (TextView)convertView.findViewById(R.id.txtInvoiceNo);
holder.txtDate = (TextView)convertView.findViewById(R.id.txtDate);
holder.txtPaymentMode = (TextView)convertView.findViewById(R.id.txtPaymentMode);
holder.txtPamentAmount = (TextView)convertView.findViewById(R.id.txtPamentAmount);
convertView.setTag(holder);
} else {
AppLog.logString(TAG+"else Null: "+position);
holder = (ViewHolder) convertView.getTag();
}
if(position-1==listPaymenIdA.size()-1){
//AppLog.logString(TAG+"if: "+position);
int color=getResources().getColor(R.color._90ffffff);
holder.txtInvoiceNo.setBackgroundColor(color);
holder.txtDate.setBackgroundColor(color);
holder.txtPamentAmount.setBackgroundColor(color);
holder.txtPaymentMode.setBackgroundColor(color);
holder.txtInvoiceNo.setTypeface(null, Typeface.BOLD);
holder.txtDate.setTypeface(null, Typeface.BOLD);
holder.txtPamentAmount.setTypeface(null, Typeface.BOLD);
holder.txtPaymentMode.setTypeface(null, Typeface.BOLD);
holder.txtInvoiceNo.setText("");
holder.txtDate.setText("Total ");
holder.txtPamentAmount.setText(""+round(total));
holder.txtPaymentMode.setText("");
}else{
//AppLog.logString(TAG+"else: "+position);
Date date1 = null;
try {
date1 = new SimpleDateFormat("yyyy/MM/dd").parse(listDateA.get(position));
} catch (ParseException e) {
e.printStackTrace();
}
formatterYY = new SimpleDateFormat("dd/MM/yyyy", Locale.US);
String todaye = formatterYY.format(date1);
holder.txtInvoiceNo.setText(""+listidA.get(position));
holder.txtDate.setText(""+todaye);
holder.txtPaymentMode.setText(""+listPaymenNameA.get(position));
holder.txtPamentAmount.setText(""+round(lisTotalAMTA.get(position)));
}
return convertView;
}
}