I know there are a lot of similar questions were asked before, but usually, they're written in Java. I followed multiple tutorials but every time there is the same error. I followed this tutorial and it worked for other scripts.
Tried this answer, but didn't work as well.
This question is unique because other question are written in java which doesn't make it any easier for me.
Here is my MainActivity
:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
NumberVerButton()
}
private fun NumberVerButton() {
next1.setOnClickListener {
startActivity(Intent(this, NumberVer::class.java))
}
}
}
And the error is the following.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.wyspiansky, PID: 20258
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.wyspiansky/com.example.wyspiansky.NumberVer}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
I just want to move to another activity by clicking a button.