sflistview exception "int android.view.ViewGroup$LayoutParams.width' on a null object reference" when refreshing

I'm currently working on expanding and collapsing logic within my listview with 2 Level group headers.
Due to a limitation of not being able to refresh the Groupheader I'm using 
`private void ListView_GroupExpanded(object sender, GroupExpandCollapseChangedEventArgs e)
{
if (e.Groups.Count > 0)
{
var group = e.Groups[0];
sfWorkoutSessionList.RefreshListViewItem(-1, -1, true);
}
}`

to refresh the listview 
but after doing this a few times or refreshing the data source, I'm faced with an exception

Java.Lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <24e422c426e0468ca1fd74b59870ff08>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <24e422c426e0468ca1fd74b59870ff08>:0 
  at Android.Widget.TextView.set_TextFormatted (Java.Lang.ICharSequence value) [0x0001f] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Widget.TextView.cs:3433 
  at Android.Widget.TextView.set_Text (System.String value) [0x0000d] in 




Attachment: expand_issue_d970a249.zip

1 Reply 1 reply marked as answer

LN Lakshmi Natarajan Syncfusion Team March 22, 2021 06:59 AM UTC

Hi Michael, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported query “sflistview exception "int android.view.ViewGroup$LayoutParams.width' on a null object reference" when refreshing” from our side. Unfortunately, we are unable to reproduce the reported scenario at our side. We have prepared a sample based on the code snippets provided and attached the tested sample and video in the link below, 
 
  
Additional information: 
Tested device: Pixel 3 XL Pie 9.0 – API 28 
SfListView version: 18.4.0.48 
Xamarin Forms: 5.0.0.2012 
Xamarin: 16.7.000.456 
Xamarin Designer: 16.7.0.495 
Xamarin Templates: 16.7.85 
Xamarin Android SDK: 11.0.2.0 
  
Could you please check our sample and let us know if you still facing the same issue? If not, please modify our sample to reproduce the issue and share the following details which will be helpful for us to check on it and provide you the solution as soon as possible. 
  • Explain the use case in detail
  • Share ListView code snippets
  • Share Issue reproducing video
  • Share Syncfusion and Xamarin.Forms versions
 
Regards, 
Lakshmi Natarajan 
 


Marked as answer
Loader.
Up arrow icon