Cześć, pod kątem Android Studio wszystko jest w porządku, ale emulator od razu zamyka aplikację :( W czym jest problem?
MainActivite.kt
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
var xxx = Xxx()
xxx.start()
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/idTextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="123456789"
tools:ignore="MissingConstraints">
</TextView>
</androidx.constraintlayout.widget.ConstraintLayout>
Xxx.kt
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
class Xxx : AppCompatActivity() {
fun start() {
idTextview.text = "987654321"
}
}