다이아로그 리스트엔 데이터를 array로 해야 됨,,,, MutableList 안됨,,,,
하지만 MutableList에 값을 담고 싶으면
tvTredeCategory가 MutableList를 array로 바꿔주는 키워드!
package com.jscompany.neerbyto.trede
import android.content.DialogInterface
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import com.jscompany.neerbyto.R
import com.jscompany.neerbyto.databinding.ActivityReportUserBinding
class ReportUserActivity : AppCompatActivity() {
private val binding:ActivityReportUserBinding by lazy { ActivityReportUserBinding.inflate(layoutInflater) }
private val builder : AlertDialog.Builder by lazy { AlertDialog.Builder(this) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
init()
}
private fun init() {
//카테고리 선택 다이아로그
binding.tvReportCategory.setOnClickListener { clickSelect() }
}
private var items: MutableList<String> = mutableListOf("카테고리","만나서 장보기","대용량 나누기","무료나눔")
private fun clickSelect() {
//카테고리 클릭 다이아로그
builder.setItems(items.toTypedArray() , DialogInterface.OnClickListener { dialog, which ->
binding.tvTredeCategory.text = items[which]
}).create().show()
}
}