Note that there are some explanatory texts on larger screens.

plurals
  1. POMono for Android: ListView Delete Items NotifyDataSet Changed
    primarykey
    data
    text
    <p>I am trying to delete rows from a listview. When I click delete, the row is removed. The ListView, however, fails to update. I have to click the back button and come back to see the item removed. Is there a way to refresh the page, after an item has been removed? Here is my code:</p> <pre><code>public class OrderHistoryAdapter : BaseAdapter { private List&lt;Order&gt; _orders; private Activity _context; public OrderHistoryAdapter(Activity context, List&lt;Order&gt; orders) { _context = context; _orders = orders; } public override View GetView(int position, View convertView, ViewGroup parent) { var item = _orders.ElementAt(position); var view = (convertView ?? this._context.LayoutInflater.Inflate( Resource.Layout.OrderHistoryDetailsRow, parent, false)) as RelativeLayout; TextView orderHistoryText = view.FindViewById&lt;TextView&gt;(Resource.Id.orderHistoryText); orderHistoryText.Text = ((Order)item).Date.ToShortDateString(); view.FindViewById&lt;TextView&gt;(Resource.Id.btnDeleteOrder).Click += delegate { OrderRepository orderRepo = new OrderRepository(); orderRepo.Delete(((Order)item).Id); //Item has been deleted, yet list fails to update NotifyDataSetChanged(); }; //Finally return the view return view; } public override int Count { get { return _orders.Count(); } } public Order GetOrder(int position) { return _orders.ElementAt(position); } public override Java.Lang.Object GetItem(int position) { return null; } public override long GetItemId(int position) { return position; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload