Skip to content Skip to sidebar Skip to footer

Why Am I Getting A Null Pointer Exception On My Android Program Line 73?

I am not entirely sure why I am getting a NullPointerException. If anybody could help me out that would be great. I labeled Line 73 below. package com.shantanu.report; import

Solution 1:

It looks to me, that line

(ViewPager) findViewById(R.id.pager);

returns null and therefore the statement mViewPager.setAdapter(mSectionsPagerAdapter); crashes. Make sure, there is a ViewPager in your xml layout.

Solution 2:

there are 2 problems I see here, b5 is null, check your xml layout to make sure you have the id right

second you are setting the content view again to a button after you already set it when you started the activity

setContentView(b5);

so you are changing the view to a button which I assume you dont want to do

Solution 3:

It's probably an issue in your activity_main.xml file.

I noticed in your comment that you declare b5 in your xml like this:

<Button android:id="@+id/b5" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:layout_below="@id/b4"/>

I can see a problem with your layout_below field. The id should match exactly how the id was declared. So, instead of "@id/b4", it should be "@+id/b4".

I would recommend posting your xml as well, because that's probably where the problem lies.

Post a Comment for "Why Am I Getting A Null Pointer Exception On My Android Program Line 73?"