HI friends.

I have listview of 4 items, each row has a remove, when i click on it, the
particular listview row is removed.
After removing 3 items, when i remove the fourth item it is not getting
removed.


Below is my getView method

@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
final ViewHolder holder;

if (convertView == null) {
convertView = mInflater.inflate(R.layout.invoice_row, null);
holder = new ViewHolder();
holder.remove = (ImageView) convertView
.findViewById(R.id.remove);
holder.productName = (TextView) convertView
.findViewById(R.id.txt_name);
holder.brand = (TextView) convertView
.findViewById(R.id.txt_brand);
holder.category = (TextView) convertView
.findViewById(R.id.txt_category);
 holder.rate = (TextView) convertView.findViewById(R.id.rate);
holder.quantity = (TextView) convertView
.findViewById(R.id.quantity);
holder.amount = (TextView) convertView
.findViewById(R.id.amount);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final View convertViewL = convertView;
if (position == this.getCount() - 1)

{
holder.remove.setVisibility(View.INVISIBLE);
holder.productName.setText("");
holder.quantity.setText("" + totalQty);
holder.quantity.setTextColor(Color.BLACK);
holder.amount.setText(df.format(totalPriceWithVat));
holder.category.setText("Total");
holder.rate.setTextColor(Color.BLACK);
holder.brand.setText("");
holder.rate.setText("");
convertViewL.setBackgroundResource(R.drawable.total_row);
} else if (position == this.getCount() - 2) {
holder.remove.setVisibility(View.INVISIBLE);
holder.rate.setTextColor(R.color.half_white);
holder.rate.setText("VAT@ ");
holder.amount.setText(df.format(vatRate));
holder.quantity.setText("12.5%");
holder.productName.setText("");
holder.category.setText("");
holder.brand.setText("");
convertViewL.setBackgroundColor(R.color.dark_ash);
} else {
holder.rate.setTextColor(Color.BLACK);
holder.remove.setVisibility(View.VISIBLE);
holder.productName
.setText(arlSellItems.get(position).getName());
holder.brand.setText(arlSellItems.get(position).getBrand());
holder.category.setText(arlSellItems.get(position)
.getCategory());
 holder.rate.setText(df.format(arlSellItems.get(position)
.getPriceValue()));
holder.quantity.setText(""
+ arlSellItems.get(position).getUserQty());
 holder.amount.setText(df.format(arlSellItems.get(position)
.getUnitListPriceValue()));
int colorPosition = position % bgColors.length;
convertView.setBackgroundResource(bgColors[colorPosition]);

holder.remove.setOnClickListener(new OnClickListener() {
 @Override
public void onClick(View v) {
System.out.println("POSITION  "+position);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage("Are you sure you want to remove this Item?")
       .setCancelable(false)
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
           arlSellItems.remove(position);
           System.out.println("SIZE "+arlSellItems.size());
           singletonInstance.setArlSellItems(arlSellItems);
           setUpdatedInfo(arlSellItems);
           notifyDataSetChanged();
           dialog.cancel();
           }
       })
       .setNegativeButton("No", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
           }
       });
AlertDialog alert = builder.create();
alert.show();
 }
});

}
return convertViewL;
}


public void setUpdatedInfo(List<SellItem> arlSelectedItems) {
arlSellItems = arlSelectedItems;
totalQty = 0;
totalPrice = 0;
vatRate = 0;
 }

How to resolve this
-- 
Regards,
Vani Reddy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to