0

Basically, I want to pick the "Name" entered at RegisterActivity.java which the user enters and transfer that to the DashboardActivity.java when it opens.
I got an error at line 51 and line 116 in dash.java.
What I tried:

  • Tried Name = (TextView)view.findViewById(R.id.textView1); instead of Name = (TextView)findViewById(R.id.textView1); at line 22at DashboardActivity.java
  • When i remove the line 116 logcat error gets removed and "Name = null" comes; I want to replace null with text entered by the user.


2019-10-20 20:42:40.868 18750-18750/com.example.seve E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.seve, PID: 18750 java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference at com.example.seve.dash.CheckEditTextStatus(dash.java:116) at com.example.seve.dash$1.onClick(dash.java:51) at android.view.View.performClick(View.java:6304) at android.view.View$PerformClick.run(View.java:24803) at android.os.Handler.handleCallback(Handler.java:794) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:6651) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

P.S: Saw atleast 8 similar questions regarding this and even referred to What is a NullPointerException, and how do I fix it?

Still i was unable to find my solution.

1 Answers1

0

Your Error log says that this NullPointerException is causing by an EditText. You are calling getText() function on an EditText which is not initialized yet (is null).

Naresh NK
  • 1,036
  • 1
  • 9
  • 16