Skip to content
Advertisement

Android Null Pointer Exception for onclick listener

The following code is giving me null pointer exception even though I can’t find anything wrong with the code. Tried commenting it out and it seems to be working. But still not able to find out what is wrong with the code? tried my own trouble shooting of commenting out the code and such and right now the code below is giving me nullpointer exception

Log Cat

12-19 05:49:14.833: E/AndroidRuntime(3392): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)’ on a null object reference 12-19 05:49:14.833: E/AndroidRuntime(3392): at com.techiequickie.bharath.boadraf.newBet_activity.onCreate(newBet_activity.java:80)

Code:

JavaScript

Advertisement

Answer

placeBet is not yet initialized that’s why it is giving null pointer exception

check the following line

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement