Why Am I Getting A Null Pointer Exception On My Android Program Line 73?
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?"