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

  • SEARCH
  • Home
  • 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 8824021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:30:14+00:00 2026-06-14T06:30:14+00:00

I got null pointer exception error right after I click button1. But I’m not

  • 0

I got null pointer exception error right after I click button1. But I’m not sure what is the route cause. Could someone help me?

public class FirstActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button button1 = (Button)findViewById(R.id.button1);
    button1.setOnClickListener(new ButtonClickListener());
}
class ButtonClickListener implements OnClickListener {
    public void onClick(View v){
        EditText name = (EditText)findViewById(R.id.name);
        EditText address = (EditText)findViewById(R.id.address);

        Spinner month = (Spinner)findViewById(R.id.month);
        Spinner day = (Spinner)findViewById(R.id.day);

        RadioGroup radio = (RadioGroup)findViewById(R.id.gendar);
        RadioButton radiobutton=
                (RadioButton)findViewById(radio.getCheckedRadioButtonId());

        CheckBox applecheck = (CheckBox)findViewById(R.id.applecheck);
        CheckBox orangecheck = (CheckBox)findViewById(R.id.orangecheck);
        CheckBox peachcheck = (CheckBox)findViewById(R.id.peachcheck);

        EditText appleqty = (EditText)findViewById(R.id.appleqty);
        EditText orangeqty = (EditText)findViewById(R.id.orangeqty);
        EditText peachqty = (EditText)findViewById(R.id.peachqty);

        Intent intent = new Intent(FirstActivity.this,SecondActivity.class);

        intent.putExtra("NAME", name.getText().toString());
        intent.putExtra("ADDRESS", address.getText().toString());
        intent.putExtra("MONTH",month.getSelectedItem().toString());
        intent.putExtra("DAY", day.getSelectedItem().toString());
        intent.putExtra("GENDAR", radiobutton.getText().toString());
        if(applecheck.isChecked())
            intent.putExtra("APPLE", appleqty.getText().toString());
        if(orangecheck.isChecked())
            intent.putExtra("ORANGE", orangeqty.getText().toString());
        if(peachcheck.isChecked())
            intent.putExtra("PEACH", peachqty.getText().toString());

        startActivity(intent);

    }
}

}

public class SecondActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);

    Bundle extra= getIntent().getExtras();

    String name = extra.getString("NAME");
    String address = extra.getString("ADDRESS");
    String month = extra.getString("MONTH");
    String day = extra.getString("DAY");
    String gendar = extra.getString("GENDAR");
    String apple = extra.getString("APPLE");
    String orange = extra.getString("ORANGE");
    String peach = extra.getString("PEACH");

11-11 14:38:38.681: E/AndroidRuntime(363): FATAL EXCEPTION: main
11-11 14:38:38.681: E/AndroidRuntime(363): java.lang.NullPointerException
11-11 14:38:38.681: E/AndroidRuntime(363): at com.example.sample4_3.FirstActivity$ButtonClickListener.onClick(FirstActivity.java:34)
11-11 14:38:38.681: E/AndroidRuntime(363): at android.view.View.performClick(View.java:2408)
11-11 14:38:38.681: E/AndroidRuntime(363): at android.view.View$PerformClick.run(View.java:8816)
11-11 14:38:38.681: E/AndroidRuntime(363): at android.os.Handler.handleCallback(Handler.java:587)
11-11 14:38:38.681: E/AndroidRuntime(363): at android.os.Handler.dispatchMessage(Handler.java:92)
11-11 14:38:38.681: E/AndroidRuntime(363): at android.os.Looper.loop(Looper.java:123)
11-11 14:38:38.681: E/AndroidRuntime(363): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-11 14:38:38.681: E/AndroidRuntime(363): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 14:38:38.681: E/AndroidRuntime(363): at java.lang.reflect.Method.invoke(Method.java:521)
11-11 14:38:38.681: E/AndroidRuntime(363): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

New error I’m having is as follows;
11-11 16:24:39.680: E/AndroidRuntime(554): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sample4_3/com.example.sample4_3.SecondActivity}: android.view.InflateException: Binary XML file line #126: Error inflating class textView
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.os.Looper.loop(Looper.java:123)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-11 16:24:39.680: E/AndroidRuntime(554): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 16:24:39.680: E/AndroidRuntime(554): at java.lang.reflect.Method.invoke(Method.java:521)
11-11 16:24:39.680: E/AndroidRuntime(554): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-11 16:24:39.680: E/AndroidRuntime(554): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-11 16:24:39.680: E/AndroidRuntime(554): at dalvik.system.NativeStart.main(Native Method)
11-11 16:24:39.680: E/AndroidRuntime(554): Caused by: android.view.InflateException: Binary XML file line #126: Error inflating class textView
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-11 16:24:39.680: E/AndroidRuntime(554): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.Activity.setContentView(Activity.java:1647)
11-11 16:24:39.680: E/AndroidRuntime(554): at com.example.sample4_3.SecondActivity.onCreate(SecondActivity.java:14)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-11 16:24:39.680: E/AndroidRuntime(554): … 11 more
11-11 16:24:39.680: E/AndroidRuntime(554): Caused by: java.lang.ClassNotFoundException: android.view.textView in loader dalvik.system.PathClassLoader[/data/app/com.example.sample4_3-2.apk]
11-11 16:24:39.680: E/AndroidRuntime(554): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
11-11 16:24:39.680: E/AndroidRuntime(554): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
11-11 16:24:39.680: E/AndroidRuntime(554): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
11-11 16:24:39.680: E/AndroidRuntime(554): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
11-11 16:24:39.680: E/AndroidRuntime(554): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
11-11 16:24:39.680: E/AndroidRuntime(554): … 23 more

Well, I can not find how to fix this error even I checked line #126.

  • 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-14T06:30:15+00:00Added an answer on June 14, 2026 at 6:30 am

    Could you highlight line 34. But from what I can readily tell from your code, in ButtonClickListener, you are accessing findViewById without using the view that is passed in as a parameter. I am not sure why thats not the error as you should not be able to do that. The other thing that could be the issue is that R.id.button1 could be misspelled, or its misspelled in the xml.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was examining the use of ServletContext when i got the null pointer exception.
I got RJS error: TypeError: element is null while using ajax. I used in
I've got exception about convert NULL to Int32. I've got a table from database
I have got a field that has been setup to allow for Null, but
Possible Duplicate: Why do I get a null pointer exception from TabWidget? I have
I got the following error: > org.apache.jasper.JasperException: An > exception occurred processing JSP page
I've got the following error: thread exiting with uncaught exception (group=0x4001b188). Nullpointerexception And this
I'm working on a JSP page, but I'm running into a null pointer at
I got an error after i tried to implement listview into my fragments. Please
I'm trying to use ShareActionProvider with actionbarsherlock, but i got: java.lang.NullPointerException at com.iuculano.tvitaliane.Start.onCreateOptionsMenu(Start.java:387) at

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.