I'm a beginner and I wanted to make a code that will print "yes" or "no" on random when the button is clicked. (Using kotlin) here's my code package com.example.calculator
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import android.view.View
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
fun buttonPressed(view: View){
val randomword = Random. ("yes" or "no")
textView.text = randomword
}
}
}
Aucun commentaire:
Enregistrer un commentaire