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

SfAccordion Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference

Hello,

I am trying to use SfAccordion but i got error while filling the list with data 

Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference

<accrod:SfAccordion ExpandMode="SingleOrNone" BindableLayout.ItemsSource="{Binding ItemInfo}">
            <BindableLayout.ItemTemplate>
                <DataTemplate>
                    <accrod:AccordionItem>
                        <accrod:AccordionItem.Header>
                            <Label Text="{Binding ItemName}"/>
                        </accrod:AccordionItem.Header>
                        <accrod:AccordionItem.Content>
                            <Label Text="{Binding ItemPrice}"/>
                        </accrod:AccordionItem.Content>
                    </accrod:AccordionItem>
                </DataTemplate>
            </BindableLayout.ItemTemplate>
        </accrod:SfAccordion>

I need help , i don't know what i has done wrong and where is my mistake

13 Replies

GP Gnana Priya Namasivayam Syncfusion Team December 9, 2019 04:36 AM

Hi Mohamed, 
 
We have checked the reported query and issue gets reproduced but only in latest version of Xamarin Forms 4.3.0.991221. You can overcome the reported issue by loading inside the container like Grid. We have reported the issue to Xamarin Team, you can follow the below bug report for further follow up. 
 
 
Please find the sample with workaround for your reference from following link. 
 
 
 
<syncfusion:SfAccordion x:Name="Accordion" BindableLayout.ItemsSource="{Binding Info}"> 
        <BindableLayout.ItemTemplate> 
            <DataTemplate> 
                <syncfusion:AccordionItem> 
                    <syncfusion:AccordionItem.Header> 
                        <Grid> 
                            <Label Text="{Binding Name}"/> 
                        </Grid> 
                    </syncfusion:AccordionItem.Header> 
                    <syncfusion:AccordionItem.Content> 
                        <Grid> 
                            <Label Text="{Binding Description}"/> 
                        </Grid> 
                    </syncfusion:AccordionItem.Content> 
                </syncfusion:AccordionItem> 
            </DataTemplate> 
        </BindableLayout.ItemTemplate> 
</syncfusion:SfAccordion> 
 
 
Please let us know if you need any further assistance form our side. 
 
Regards, 
Gnana Priya N 



MO mohamed December 9, 2019 09:59 AM

hello again , 

Thanks for the replying, 

1st: i have a problem to use latest version of Xamarin Forms 4.3.0.991221 coz i got error after installing it can i use  version 4.3.0.991211 instead ?

2nd : is there is event for the sfAccordion Like (OnExpanding - OnExpanded - OnCollapsed - ..... etc ) or i have no control on the headerGroup ?

3rd: i did a trick to make 4.3.0.991221 work with me i changed Xamarin.Forms.Platform.iOS.dll to the preveos version of 4.3.0.991211 so the application worked and the SfAccordion appears in IOS only and not appearing at all in andriod . and in IOS the list is not clickable or expanbale 



Thanks.


GP Gnana Priya Namasivayam Syncfusion Team December 10, 2019 02:35 AM

Hi Mohamed, 
 
Please find the following details for the reported query, 

Query1 :  
Yes. You can use Xamarin forms version 4.3.0.991211. 
 
Query 2 : 
In Accordion, you can use Expanded, Expanding, Collapsed & Collapsing events. You can customize accordion view based on your requirements using these events. 

Query 3: 
We suggest you to use Xamarin version 4.3.0.991211 which works fine in all three platforms. Kindly stick to this version until the reported issue fixes in Xamarin forms.  
 
Please let us know if you have any further queries regarding listview. 
 
Regards, 
Gnana Priya N 



MO mohamed December 10, 2019 09:57 AM

Hello,

1st : I downgraded the Xamarin.Forms to 4.3.0.991211 and the application works fine without errors in IOS and Andriod.

2nd: I Updated all Syncfusion controls to the latest releases today Version: 17.3.0.34.

3rd:  In IOS Device (Iphone7) and Andriod the SfAccordion Appears after setting the row height of the grid container
                                   
                                       
                                   




MO mohamed December 10, 2019 10:09 AM

Hello,

I fixed my problem for IOS & Andriod After setting Grid row height every thing worked as expected but The RTL (Flow direction) didn't work with IOS and it works for Android fine, is there is anyway to Make RTL works for IOS ?

Solution for appearing in IOS & Andriod and make the Expandable event works:
                                   <Grid.RowDefinitions>
                                        <RowDefinition Height="400" />
                                    </Grid.RowDefinitions>



MO mohamed December 11, 2019 01:36 AM

Hello,

I just figure out that the HeaderIconPosition in IOS is not appears correctly when i set it to End it shows in Start and when i set it to End it Shows at Start this for IOS Only , Android works Fine.

so that what i did to solve this in RTL:

if (CrossMultilingual.Current.CurrentCultureInfo.EnglishName == "Arabic")
            {

                this.FlowDirection = FlowDirection.RightToLeft;
                if (Device.RuntimePlatform == Device.iOS)
                {
                    Accordion.HeaderIconPosition = Syncfusion.XForms.Expander.IconPosition.Start;      //  <---- this will show it at the End ( is it a bug ??)
                }
                else if (Device.RuntimePlatform == Device.Android)
                {
                    Accordion.HeaderIconPosition = Syncfusion.XForms.Expander.IconPosition.End;
                }
                
            }


SP Subburaj Pandian Veluchamy Syncfusion Team December 11, 2019 04:35 AM

Hi Mohamed, 
 
Thank you for the update.

Regarding Label positing in RTL: We have checked the issue with the sample, as default all the Accordion elements loading property in RTL mode. When handling Label position, there is a known framework issue there in RTL mode.

Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AccordionSample-844239292.zip

Also, check the attached sample as we loaded with lower Xamarin.Forms version and confirm your Xamarin.Forms update version, it will be helpful for us to proceed further?

Regards,
Subburaj Pandian V 



MO mohamed December 11, 2019 04:47 AM

Hello,

Thanks for your support and sample. and i am still using Xamarin.Forms 4.3.0.991211.

i am just waiting for how to collapse item from code behind but i posted in another thread thanks.


GP Gnana Priya Namasivayam Syncfusion Team December 12, 2019 02:45 AM

Hi  Mohammed, 
 
We would like to inform that when RTL is defined to Accordion, HeaderIcon positions as expected in both Android and iOS. Meantime, please confirm us whether you have added the RightToLeft language in the CFBundleLocalizations section of your Info.plist file like below. 
 
 
<resources> 
        <key>CFBundleDevelopmentRegion</key> 
               <string>en</string> 
        <key>CFBundleLocalizations</key> 
        <array> 
                <string>en</string> 
                <string>ar</string> 
        </array> 
</resources> 
 
 
We have attached the screenshot for your reference, kindly find them below following link. 
 
 
If the reported issue still replicates then revert us back with the issue replicated or modified sample so that we could validate and provide you appropriate solution at our end. 
 
Regards, 
Gnana Priya N 



MO mohamed December 12, 2019 03:49 AM

Hello,

I tried to edit the info.plist like u mentioned but it didnt change anything, i don't know what i am missing

this is my info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

<dict>
  <key>CFBundleDevelopmentRegion</key>
  <string>en</string>
  <key>CFBundleLocalizations</key>
  <array>
    <string>en</string>
    <string>ar</string>
  </array>


  <key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIAppFonts</key>
<array>
<string>UIFontIcons.ttf</string>
<string>Montserrat-Bold.ttf</string>
<string>Montserrat-Medium.ttf</string>
<string>Montserrat-Regular.ttf</string>
<string>Montserrat-SemiBold.ttf</string>
</array>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>CFBundleDisplayName</key>
<string>MLKApp</string>
<key>CFBundleIdentifier</key>
<string>com.Moci.MociApp</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleName</key>
<string>MLKApp</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
</dict>
</plist>



GP Gnana Priya Namasivayam Syncfusion Team December 13, 2019 04:39 AM

Hi Mohammed, 
 
 
We would like to inform that reported issue does not occur in our side. Can you please confirm us whether reported issue occur in framework also? If possible share issue replicated sample or modified sample in order to check the reported issue in your sample. If you face any difficulties in replicating in the provided sample, we can setup web-meeting to avoid further delay. Kindly confirm your availability for the web meeting so that we can investigate and provide you the solution at the earliest.   
 
 
Regards, 
Gnana Priya N 



MO mohamed December 13, 2019 01:57 PM

Thanks for the reply but my problem sovled by this code , i just invert IconPosition.Start IconPosition.End in IOS and it works well, and for Android nothing needs to change it works well. Thanks

if (CrossMultilingual.Current.CurrentCultureInfo.EnglishName == "Arabic")
            {

                this.FlowDirection = FlowDirection.RightToLeft;
                if (Device.RuntimePlatform == Device.iOS)
                {
                    Accordion.HeaderIconPosition = Syncfusion.XForms.Expander.IconPosition.Start;      
                }
                else if (Device.RuntimePlatform == Device.Android)
                {
                    Accordion.HeaderIconPosition = Syncfusion.XForms.Expander.IconPosition.End;
                }
                
            }



GP Gnana Priya Namasivayam Syncfusion Team December 15, 2019 09:36 PM

Hi Mohammed, 
 
Thanks for the update. 
 
We are glad that reported issue have been fixed in your application. Please let us know if you need any further assistance from us. 
 
Regards, 
Gnana Priya N 


Loader.
Live Chat Icon For mobile
Up arrow icon