c# - Java.Lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification (xamarin.forms) -


i have bound 1 list web service. first time 5 items loaded , when user scroll list view other 5 items loaded. every thing working fine facing issue in 1 scenario. first time when list bound (don't scrolling) , if clicked on list item "itemtepped" event fired , page should navigated other page problem showing me error below image.

error image

i have put active indicator loading.

this code in xamarin.forms (portable library). not xamarin.android project.

public partial class newsgallerylistpage : contentpage     {         int totalitems = 0;         decimal maxindex = 0;         int index = 0;         list<newslist> newslist;         public newsgallerylistpage()         {             initializecomponent();              newsgallerylists.itemtapped += newsgallerylists_itemtapped;             newsgallerylists.itemappearing += newsgallerylists_itemappearing1;             loadingindicator.isvisible = true;             loading.isrunning = true;             loading.isvisible = true;             callwebservicefornewsgallerylist(index);         }          private void newsgallerylists_itemappearing1(object sender, itemvisibilityeventargs e)         {             try             {                 if (totalitems != 0)                 {                     maxindex = math.ceiling(((decimal)totalitems) / 5);                     if (index < maxindex)                     {                         if (newslist != null && e.item != null && e.item == newslist[newslist.count - 1])                         {                             index++;                             if (index != maxindex)                             {                                 loadingindicator.isvisible = true;                                 loading.isvisible = true;                                 loading.isrunning = true;                                 callwebservicefornewsgallerylist(index);                             }                         }                     }                 }             }             catch(exception ex)             {              }         }          private void newsgallerylists_itemtapped(object sender, itemtappedeventargs e)         {             var selectednewsgallerylistitem = sender xamarin.forms.listview;             var obj = selectednewsgallerylistitem.selecteditem cmo.servicesclasses.newslist;             navigation.pushasync(new cmo.gallery.newsgallerydetail(obj));         }         public async void callwebservicefornewsgallerylist(int index)         {             try             {                 string lang = "en";                  if (application.current.properties.containskey("language"))                 {                     lang = application.current.properties["language"] string;                     //                 }                 list<keyvaluepair<string, string>> values = new list<keyvaluepair<string, string>>();                 values.add(new keyvaluepair<string, string>("lang",lang));                 values.add(new keyvaluepair<string, string>("title", ""));                 values.add(new keyvaluepair<string, string>("index", convert.tostring(index)));                 values.add(new keyvaluepair<string, string>("limit", "5"));                 var response = await generalclass.getresponse<cmo.servicesclasses.rootobjectnewsgallerylist>("http://14.141.36.212/maharastracmo/api/getnewslist", values);                 if (response != null)                 {                      if (newslist == null || index==0)                     {                         newslist = new list<newslist>();                     }                     for(int = 0; < response.newslist.count; i++)                     {                         var objectnewslist = new newslist();                         objectnewslist.page_id = response.newslist[i].page_id;                         objectnewslist.title = response.newslist[i].title;                         objectnewslist.date = response.newslist[i].date;                         objectnewslist.news_photo = response.newslist[i].news_photo;                         objectnewslist.content = response.newslist[i].content;                         newslist.add(objectnewslist);                     }                     totalitems = response.total_results;                     newsgallerylists.rowheight = 100;                     var x = newsgallerylists.rowheight;                     this.title = appresources.lnewsgallery;                     newsgallerylists.itemssource = newslist;                 }             }             catch (webexception exception)             {             }             loading.isvisible = false;             loading.isrunning = false;             loadingindicator.isvisible = false;         }     } 

i have gone through following link

https://forums.xamarin.com/discussion/23124/proper-way-to-update-the-tableviews-sections-content https://forums.xamarin.com/discussion/21994/threading-in-xamarin-forms

i have tried

xamarin.forms.device.begininvokeonmainthread (() =>         {});  task.run(() => { }); 

i don't know how handle thread in xamarin forms beginner level.

it happens when use templateselector, creating new 1 each row. create 1 instance of templateselector , use it.


Comments