1 Replies - 316 Views - Last Post: 29 November 2016 - 08:52 AM

#1 Nova6112   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 28-November 14

Nullpointer Exception fromn the following line

Posted 29 November 2016 - 06:08 AM

Hi guys i am getting the following stracktrace

Quote

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.setText(java.lang.CharSequence)' on a null object reference --------- Stack trace --------- mypackage.Inbox$9.onclick(Inbox.java:1538) android.view.View.performClick(View.java:5204) android.view.View$PerformClick.run(View.java:21153) android.os.Handler.handleCallback(Handler.java:739) android.os.Handler.dispatchMessage(Handler.java:95) android.os.Looper.loop(Looper.java:148) android.app.ActivityThread.main(ActivityThread.java:5444) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:746) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636) ------------------------------- --------- Cause --------- -------------------------------


from the code
double taxvalue = 0.0;
double acttotal=Global.getDouble(((EditText)container.findViewById(R.id.textView9)).getText().toString());
taxvalue = Global.getDouble(((EditText) container.findViewById(R.id.textView8)).getText().toString());
((EditText) (table.getChildAt(1).findViewById(R.id.amount))).setText(Global.formatDouble(acttotal - taxvalue));


Here
table - LinearLayout, Last line is Line no 1538.

i tried table=null;
But cannot be reproduced. what is the chance to get this issue.

Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Nullpointer Exception fromn the following line

#2 EndLessMind   User is offline

  • Android Expert
  • member icon

Reputation: 273
  • View blog
  • Posts: 1,252
  • Joined: 13-March 09

Re: Nullpointer Exception fromn the following line

Posted 29 November 2016 - 08:52 AM

The findViewById is returning null, that's the cause of the exception.

Is 'amount' actually present in the child view?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1