이번엔 기능 및 동작에 실질적으로 관련된 MainActivity.kt을 다뤄보겠다.
버튼과 EditText같은 기능들을 동작하도록 하기위해서는 주소인 고유 Id값을 부여해주고 코틀린으로 동작시켜야한다.
형태는 다음과 같다.
android:id="@+id/heightEditText"
이 주소값은 mainactivity.kt 에서 주소값을 불러와 사용한다.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val heightEditText:EditText = findViewById(R.id.heightEditText)
val weightEditText = findViewById<EditText>(R.id.weightEditText)
val resultButton: Button = findViewById(R.id.resultButton)
}
}