작성
·
469
0
답변 2
0
package com.ohman.dice_app
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import com.ohman.dice_app.databinding.ActivityMainBinding
import java.util.*
import kotlin.random.Random
class MainActivity : AppCompatActivity() {
private lateinit var binding : ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
binding.diceStartBtn.setOnClickListener {
Toast.makeText(this, "주사위 GO!", Toast.LENGTH_LONG).show()
Random.nextInt
}
}
}
//9번째줄 맨 마지막 Random과 25번째줄 nextInt가 빨간색으로 표시되고 Unresolved reference로 나옵니다.
0
package com.ohman.dice_app
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import com.ohman.dice_app.databinding.ActivityMainBinding
import java.util.*
import kotlin.random.Random
class MainActivity : AppCompatActivity() {
private lateinit var binding : ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
binding.diceStartBtn.setOnClickListener {
Toast.makeText(this, "주사위 GO!", Toast.LENGTH_LONG).show()
Random.nextInt
}
}
}
//9번째줄 맨 마지막 Random과 25번째줄 nextInt가 빨간색으로 표시되고 Unresolved reference로 나옵니다.
import java.util.*
위의 부분을 삭제하시고
아래와 같이 사용해보시겠어요?
만약 그래도 안되면 전체 코드를 복사해서 공유해주세요.