I am trying to set predefined text in EditText field but it is empty. Please take a look at the code
var yes: Button? = null
var no: Button? = null
private lateinit var title : EditText
private lateinit var description : EditText
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.dialog_template)
title = findViewById(R.id.dialog_title)
description = findViewById(R.id.dialog_description)
val lp = WindowManager.LayoutParams()
lp.copyFrom(this.window?.attributes)
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.height = WindowManager.LayoutParams.WRAP_CONTENT
lp.gravity = Gravity.CENTER
this.window?.attributes = lp
yes = findViewById<Button>(R.id.dialogOkButton)
no = findViewById<Button>(R.id.dialogCancelButton)
yes?.setOnClickListener(this)
no?.setOnClickListener(this)
if (isEditMode){
prepareUpdateData()
} else {
prepareEmptyData()
}
}
private fun prepareEmptyData() {
title.setText(toDoItem.title) // <--- HERE NOT WORKING
description.text = Editable.Factory.getInstance().newEditable(toDoItem.description)--- HERE NOT WORKING
}