When I click on the button in an attempt to open the next activity, the application crashes (I want to open fctivity registration) here's the code:
package com.greenprojectinfo.ideabank import android.content.Intent import android.support.v7.app.AppCompatActivity import android.os.Bundle class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val btnTA = findViewById(R.id.btnTA) btnTA.setOnClickListener { val intent = Intent(this, Donation::class.java) startActivity(intent) } val btnDon = findViewById(R.id.btnDon) btnDon.setOnClickListener { val intent = Intent(this, TakingAway::class.java) startActivity(intent) } val btnMEN = findViewById(R.id.btnMEN) btnMEN.setOnClickListener { val intent = Intent(this, Mentor::class.java) startActivity(intent) } val btnMon = findViewById(R.id.btnMon) btnMon.setOnClickListener { val intent = Intent(this, Fond::class.java) startActivity(intent) } val btnSql = findViewById(R.id.btnSql) btnSql.setOnClickListener { val intent = Intent(this, Registration::class.java) startActivity(intent) } }
Here is the xml code:
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:background="@drawable/kek" > <Button android:text="ИДЕИ ДЛЯ ПРОЕКТА" android:layout_width="220dp" android:textColor="#FFFFFF" android:layout_height="60dp" android:id="@+id/btnTA" android:background="@drawable/zubenko" app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="61dp" app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="95dp" android:layout_marginStart="95dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="96dp" android:layout_marginRight="96dp" android:layout_marginBottom="133dp" app:layout_constraintBottom_toTopOf="@+id/btnMEN"/> <Button android:text="ПРЕДЛОЖИТЬ ИДЕЮ" android:textColor="#FFFFFF" android:layout_width="220dp" android:layout_height="60dp" android:id="@+id/btnDon" android:background="@drawable/zubenko" android:layout_marginTop="100dp" app:layout_constraintTop_toBottomOf="@+id/btnMEN" app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="104dp" android:layout_marginStart="104dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="104dp" android:layout_marginRight="104dp"/> <Button android:text="МЕНТОРЫ" android:textColor="#FFFFFF" android:layout_width="220dp" android:layout_height="60dp" android:id="@+id/btnMEN" android:background="@drawable/zubenko" android:layout_marginTop="100dp" app:layout_constraintTop_toBottomOf="@+id/btnTA" app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="104dp" android:layout_marginStart="104dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="104dp" android:layout_marginRight="104dp"/> <Button android:text="ФОНДЫ" android:background="@drawable/zubenko" android:textColor="#fff" android:layout_width="220dp" android:layout_height="60dp" android:id="@+id/btnMon" android:layout_marginTop="100dp" app:layout_constraintTop_toBottomOf="@+id/btnDon" app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="104dp" android:layout_marginStart="104dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="104dp" android:layout_marginRight="104dp"/> <Button android:text="Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnSql" android:layout_marginTop="47dp" app:layout_constraintTop_toBottomOf="@+id/btnMon" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginBottom="34dp" app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="161dp" android:layout_marginStart="161dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="162dp" android:layout_marginRight="162dp" /> </android.support.constraint.ConstraintLayout>