I have a GridView adapter and I have a ImageButton
to delete the items. It is deleting correctly, however, every time an item is deleted I need to set the current quantity to a TextView
that is in another Activity
. I can not get the GridView
event directly, because as it has other clickable components, your ringtone has been disabled:
Here is the code snippet where I exclude the item and try to pass the current amount of items to TextView
in my Activity
:
holder.imgDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Integer position = (Integer)v.getTag();
Produto_Valor newList[] = new Produto_Valor[values.length - 1];
int count = 0;
for (int i = 0; i < values.length; i++) {
if (values.length - 1 > 0) {
if (values[i] == values[1]) {
} else {
newList[count] = values[i];
count++;
}
}
}
values = newList;
notifyDataSetChanged();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.activity_pedidos, null);
final TextView txtTotal = (TextView) view.findViewById(R.id.lbl_QtdeDados);
new Thread (new Runnable(){
@Override
public void run(){
txtTotal.setText(String.valueOf(values.length));
}
}).start();
}
});