Cannot fix Java null pointer error

前端 未结 4 705
悲哀的现实
悲哀的现实 2021-01-29 06:19

I have some code that when I run it returns a null pointer error. This is the code and error from the logcat:

import android.support.v7.app.AppCompatActivity;
im         


        
4条回答
  •  故里飘歌
    2021-01-29 07:01

    In your Layout, you say:

    android:onClick="onClick"
    

    It appears that you did not include all of the code for the Activity but I'd bet that it does not define a method named onClick

    All you need to do is define the method.

提交回复
热议问题