I have a list view populate with numbers, and a edit text that sum the amount of numbers in the list view, I have written a implementation of ontouch, to delete rows in the list view, my question is: is there a way to delete the value that I delete in the list view on the edit text. for example if I delete the row 7 of 10 rows and its has a value of 5, and the amount is 35 display on the edit text, now the edit text must have 30.
thank you I will appreciate it
here some codes:
private void showListViewData() {
String z = "";
String zQN = "Nu";
String zPL = "Pl";
String zTR = "Tr";
int x = Integer.parseInt(inJugada.getText().toString());
int y = Integer.parseInt(inValor.getText().toString());
String s = Integer.toString(x);
inJugada.setText(s);
inValor.setText(String.valueOf(y));
if(s.length() == 2){
z = zQN;
}else if(s.length() == 4){
z = zPL;
}else if(s.length() == 6){
z = zTR;
}
for(int i=0; i<mData.size(); i++)
mData.get(i);
mData.add(new Data(z, x, y));
Collections.sort(mData);
Collections.synchronizedCollection(mData);
// add new data to list and refresh
mAdapter.notifyDataSetChanged();
If you need to delete item whit ontouch, or click you will need adapter and onClick. I have list of arrays where i set the different variables “ArrayList items”. Every time i get the variable i put it in this “items”, then whit adapter i display in list view and on click i can make what ever i want whit item[i].
then you can call a method to calculate your variables whit simple for method.