We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting an odd error with rotator datasource

Thread ID:





144440 May 6,2019 07:56 PM UTC May 14,2019 02:54 AM UTC Android 6
Tags: SfRotator
Mark Eric
Asked On May 6, 2019 07:56 PM UTC

Hello !| 

I am trying to use rotator in normal layout, but I am getting an odd error saying " NullReferenceException: Object reference not set to an instance of an object.
 " while I am setting the datasource ! 

here is a snippet of my code 

     List<Com.Syncfusion.Rotator.SfRotatorItem> images = new List<Com.Syncfusion.Rotator.SfRotatorItem>();
            List<int> imageID = new List<int>();
            Context context = this;

            Com.Syncfusion.Rotator.SfRotatorItem item;
            ImageView image;
            for (int i = 0; i < imageID.Count; i++)
                item = new Com.Syncfusion.Rotator.SfRotatorItem(context);
                image = new ImageView(context);
                item.Content = image;

            Com.Syncfusion.Rotator.SfRotator rotator = FindViewById<Com.Syncfusion.Rotator.SfRotator> (Resource.Id.imageRotator);

Mark Eric
Replied On May 6, 2019 09:43 PM UTC

I am using this method as reference : 

Muneesh Kumar G [Syncfusion]
Replied On May 7, 2019 10:24 AM UTC

Hi Mark Eric, 
Thanks for using Syncfusion products, 
We have analyzed your query and we would like to inform you that NullReferenceException occurs due to the control instance passing to SetContentView method. 
If you initialize the control in axml page, then we don’t need to pass the view to SetContentView method. You can resolve this problem by passing the axml page resource layout id itself as per the below code snippet. 
Code snippet: 
SfRotator rotator = FindViewById<SfRotator>(Resource.Id.sfRotator1); 
List<SfRotatorItem> rotatorItems = new List<SfRotatorItem>(); 
List<int> images = new List<int>(); 
for (int i = 0; i < images.Count; i++) 
    SfRotatorItem sfRotatorItem = new SfRotatorItem(this); 
    ImageView imageView = new ImageView(this); 
    sfRotatorItem.Content = imageView; 
rotator.DataSource = rotatorItems; 
We have created sample for your requirement. Please download the sample from below location. 
Please let us know if you have any queries.  
Muneesh Kumar G  

Mark Eric
Replied On May 8, 2019 11:56 PM UTC

Thanks so much for your help, Would you let me know how I can make the image stretch to fix the whole rotator? !

Mark Eric
Replied On May 9, 2019 02:45 AM UTC

Thanks , 
I already solved using 

Muneesh Kumar G [Syncfusion]
Replied On May 9, 2019 05:26 AM UTC

Hi Mark Eric,  
Glad that the issue has been resolved and please get back to us if you need any other assistance.  
Muneesh Kumar G   

Mark Eric
Replied On May 14, 2019 02:54 AM UTC

Thanks ! 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon