작성
·
134
0
package com.example.diet_memo
import android.app.DatePickerDialog
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.Button
import android.widget.DatePicker
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import java.util.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val writeButton = findViewById<ImageView>(R.id.writebtn)
writeButton.setOnClickListener{
val mDialogView = LayoutInflater.from(this).inflate(R.layout.custom_dialog,null)
val mBuilder = AlertDialog.Builder(this)
.setView(mDialogView)
.setTitle("운동 메모 다이얼로그")
val mAlertDialog = mBuilder.show()
val Dateselectbtn = mAlertDialog.findViewById<Button>(R.id.selectdate)
Dateselectbtn?.setOnClickListener{
val today = GregorianCalendar()
val year : Int = today.get(Calendar.YEAR)
val month : Int = today.get(Calendar.MONTH)
val date : Int = today.get(Calendar.DATE)
val dlg = DatePickerDialog(this,object: DatePickerDialog.OnDateSetListener{
override fun onDateSet(p0: DatePicker?, p1: Int, p2: Int, p3: Int) {
Dateselectbtn.setText("${year},${month + 1},${dayOfMonth}")
}
},year,month,date)
dlg.show()
}
여기에서 dayOfMonth 부분에 빨간 에러가 뜨는데
에러가 뜨는 이유가 궁금합니다.
항상 강의 잘 듣고 있습니다. 감사합니다!!