Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8882329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:33:04+00:00 2026-06-14T20:33:04+00:00

I get a nullpointer exception here is the code where its laying. final TextView

  • 0

I get a nullpointer exception here is the code where its laying.

    final TextView view = (TextView) findViewById(R.id.textView2);
final Button next = (Button) findViewById(R.id.button1);
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    next.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            view.setText("These questions will help me to help you :)");
        }
    });

This is my log file:

24 15:21:45.441: E/AndroidRuntime(376): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.icemountaininc.app/com.icemountaininc.app.MainActivity}: java.lang.NullPointerException
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.ActivityThread.access$1500(ActivityThread.java:123)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.os.Looper.loop(Looper.java:126)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.ActivityThread.main(ActivityThread.java:3997)
11-24 15:21:45.441: E/AndroidRuntime(376):  at java.lang.reflect.Method.invokeNative(Native Method)
11-24 15:21:45.441: E/AndroidRuntime(376):  at java.lang.reflect.Method.invoke(Method.java:491)
11-24 15:21:45.441: E/AndroidRuntime(376):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-24 15:21:45.441: E/AndroidRuntime(376):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-24 15:21:45.441: E/AndroidRuntime(376):  at dalvik.system.NativeStart.main(Native Method)
11-24 15:21:45.441: E/AndroidRuntime(376): Caused by: java.lang.NullPointerException
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.Activity.findViewById(Activity.java:1741)
11-24 15:21:45.441: E/AndroidRuntime(376):  at com.icemountaininc.app.MainActivity.<init>(MainActivity.java:14)
11-24 15:21:45.441: E/AndroidRuntime(376):  at java.lang.Class.newInstanceImpl(Native Method)
11-24 15:21:45.441: E/AndroidRuntime(376):  at java.lang.Class.newInstance(Class.java:1424)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
11-24 15:21:45.441: E/AndroidRuntime(376):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
11-24 15:21:45.441: E/AndroidRuntime(376):  ... 11 more

Any help please?

Been stuck on this problem for ages!

I use SDK VERSION 8 of android

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:33:05+00:00Added an answer on June 14, 2026 at 8:33 pm

    Actually You got NullPointerException because Your TextView view and Button next are NULL.

    Solution:

    You have to define TextView view and Button next after setContentView() method in onCreate() of your Activity.

    like:

    setContentView(R.layout.activity_main);
    final TextView view = (TextView) findViewById(R.id.textView2);
    final Button next = (Button) findViewById(R.id.button1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just trying to fill my ListView but I get a NullPointerException Here
//get the lat and loni throgh the loaddata function.java.util.ConcurrentModificationException at java.util.AbstractList$SimpleListIterator.next(AbstractList.java:64) How to resolve
Here's my code: class Collar { int size; } class Dog implements Serializable {
This code is causing a null pointer exception. I have no idea why: private
I have a little issue with Android SQL queries. Here is the my code
Here is my code where the problem happens, I've bolded line 90 (where the
I get a NullPointerException in my onCreate method in some activities. It's hard to
When I try to call any GL15 function in lwjgl I get A NullPointerException.
It doesn't seem to be working right now. I get a java.lang.NullPointerException I have
Get class from div inside an li and add to the same li. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.