Delete listview item in Xamarin

Asked

Viewed 202 times

1

How do I delete an item from my listview? I delete the item, but when I click on the next item the same item I deleted is selected.

My code:

adapter.Remove("LISTA 1");
adapter.Remove("LISTA 2");
adapter.Remove("LISTA 3");
adapter.Remove("LISTA 4");
  • do you using Observablecollection in your itemsource? Just for the record, this is Stackoverflow in Portuguese, if you are Brazilian, here you can post the question in Pt msm.

  • I am not using !

  • Please translate your question or it will be closed by the community.

1 answer

1


Well, I think I can try some of the points I’m going to list below:

  • Make sure your Adapter has an overload to use an Observablecollection instead of the List, as the observablecollection will notify you when something changes.

  • You can set your Adapter again after removing the item from your list, so you load a list already without the item that has been removed

  • You can check the operation of Notifydatasetchanged of your Adapter, it would be the same functioning of the Observablecollection that I listed first.

  • Thanks for the tip Briansouza, making set of the Adapter again worked very well, wanted to take the opportunity ask you know how to change an item of the color listview ?

  • Oops, thanks. Mark as an answer because your question may be the same as others. Don’t forget to edit your post to leave it in the Stack template. About your question, open another post so we can separate topics.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.