Java.Lang.NullPointerException

fakhravarifakhravari Member ✭✭✭
edited January 16 in Xamarin.Forms

Hi
On the first page I have the following controls
Xam.Plugin.TabView

TabItem 5

sometimes TabItem 1 to 2 or 3 4 5
What can be the problem

Java.Lang.NullPointerException: 'Attempt to invoke virtual method 'void android.graphics.Rect.set(android.graphics.Rect)' on a null object reference'

Can it be used without tools Xam.Plugin.TabView ، tabpage Created ??

I want to open tabpage in the middle of the page ContentPage

how can include TabbedPage to ContentPage?

Best Answer

  • JarvanJarvan Xamurai
    Accepted Answer

    Hi, I've tested the sample on my side and the exception occurs when navigating in the tabView. I noticed that you added a lot of views in the Home page. Try to use ContentView to reference the code and introduce the contentViews in Home page to display the views.

    <StackLayout HeightRequest="600">
    
        <tabview:TabViewControl HeaderBackgroundColor="#430033" BackgroundColor="Transparent" HeaderSelectionUnderlineColor="#ccca39" FlowDirection="RightToLeft" 
                        HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" x:Name="theTabView">
            <tabview:TabViewControl.ItemSource>
    
                <tabview:TabItem HeaderText="محصولات برجسته">
                    <local:View1/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="آخرین محصولات">
                    <local:View2/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="پربازدید ترین">
                    <local:View3/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="پرامتیاز ترین">
                    <local:View4/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="محبوب ترین">
                    <local:View5/>
                </tabview:TabItem>
    
            </tabview:TabViewControl.ItemSource>
        </tabview:TabViewControl>
    
    </StackLayout>
    

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Java.Lang.NullPointerException: 'Attempt to invoke virtual method 'void android.graphics.Rect.set(android.graphics.Rect)' on a null object reference'

    We couldn't reproduce this question, could you please post a basic demo so that we can test on our side?

    Besides,I couldn't fully understand the means by words:

    TabItem 5

    sometimes TabItem 1 to 2 or 3 4 5
    What can be the problem

  • fakhravarifakhravari Member ✭✭✭

    hi
    please check sample

    Quickly click on the headers and scroll down the list

  • JarvanJarvan Member, Xamarin Team Xamurai
    Accepted Answer

    Hi, I've tested the sample on my side and the exception occurs when navigating in the tabView. I noticed that you added a lot of views in the Home page. Try to use ContentView to reference the code and introduce the contentViews in Home page to display the views.

    <StackLayout HeightRequest="600">
    
        <tabview:TabViewControl HeaderBackgroundColor="#430033" BackgroundColor="Transparent" HeaderSelectionUnderlineColor="#ccca39" FlowDirection="RightToLeft" 
                        HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" x:Name="theTabView">
            <tabview:TabViewControl.ItemSource>
    
                <tabview:TabItem HeaderText="محصولات برجسته">
                    <local:View1/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="آخرین محصولات">
                    <local:View2/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="پربازدید ترین">
                    <local:View3/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="پرامتیاز ترین">
                    <local:View4/>
                </tabview:TabItem>
    
                <tabview:TabItem HeaderText="محبوب ترین">
                    <local:View5/>
                </tabview:TabItem>
    
            </tabview:TabViewControl.ItemSource>
        </tabview:TabViewControl>
    
    </StackLayout>
    

  • fakhravarifakhravari Member ✭✭✭
    thanks
  • fakhravarifakhravari Member ✭✭✭

    hi

    convert to comtetnview




    but error

    Java.Lang.NullPointerException: 'Attempt to invoke virtual method 'void android.graphics.Rect.set(android.graphics.Rect)' on a null object reference'

    Continued error

    Not using TabViewControl

Sign In or Register to comment.