3

I have created a Linear Layout onclick of a button which has an edit text. While typing there is a popup window for suggestions that comes up and the app crashes.

Stack trace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
       at android.widget.Editor$SuggestionsPopupWindow.initContentView(Editor.java:3714)
       at android.widget.Editor$PinnedPopupWindow.(Editor.java:3375)
       at android.widget.Editor$SuggestionsPopupWindow.(Editor.java:3660)
       at android.widget.Editor.replace(Editor.java:423)
       at android.widget.Editor$3.run(Editor.java:2340)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6682)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

I found some related answers which stated that this happens on using Android PopupWindow class since the suggestions are using a PopupWindow as well. My code does not use PopupWindow as well.

This crash is happening mostly on Samsung Note 5, and Galaxy S6.

Any help would be appreciated!

Curio
  • 1,331
  • 2
  • 14
  • 34
Lavina Advani
  • 61
  • 1
  • 4
  • Cause is view object is null while you are adding click listener. make null check before setting listener to view object. – Keyur Thumar May 31 '17 at 16:47
  • Please go ahead and post your java and xml code – Red M May 31 '17 at 17:21
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Jozef Dochan May 31 '17 at 17:24

2 Answers2

1

It's saying that your button (which you used like buttonName.setOnClickListener()) is not defined. Check your find view by id function, id inside of it etc.

Mohamed
  • 1,251
  • 3
  • 15
  • 36
0

I think it is because you set in XML a click, but don't have in your class. A check has this tag and remove:

android:onClick="save"
Uzias
  • 101
  • 5