Adapter modified in real time

0

I have a Activity called ListaBasica and a Adapter with the name adapterBasico . Adapter contains a list of bulletins. The Activity contains information taken from the Adapter as the sum of the time reported in the bulletin.

My question is this: when I delete some items from Adapter I need to have Activity updated. I would like to know if there is any way to check if Adapter has undergone some kind of change, as with EditText when using:

  EditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

Is there something like this to check Adapter ?

    
asked by anonymous 29.08.2016 / 14:42

2 answers

1

After deleting the desired item, you should add the following line:

adapter.notifyDataSetChanged();
    
29.08.2016 / 14:48
0

You can simply remove the desired item from the list using the remove() method of your ArrayAdapter . Where one possible way to do this would be:

Objeto item = arrayAdapter.getItem([INDEX]);
arrayAdapter.remove(item);

So then how to modify ArrayList and call notifyDataSetChanged() in ArrayAdapter , which by disengagement of consciousness, can first check if arrayAdapter exists in this way:

if(arrayAdapter!=null){
    arrayList.remove([INDEX]);
    arrayAdapter.notifyDataSetChanged();
}
    
29.08.2016 / 15:46