Closed kalanidhidev closed 5 years ago
You can use OnDateSetListener
for the OK action button.
On Cancel button click dialog get dismissed and there is no public listener exposed.
MonthPickerDialog.Builder builder = new MonthPickerDialog.Builder(MainActivity.this, new MonthPickerDialog.OnDateSetListener() { @Override public void onDateSet(int selectedMonth, int selectedYear) { // on date set } }, today.get(Calendar.YEAR), today.get(Calendar.MONTH));
Got the answer and working fine
val b = MonthPickerDialog.Builder(context,
MonthPickerDialog.OnDateSetListener { _, _ ->
// on date set }
}, today.get(Calendar.YEAR), today.get(Calendar.MONTH)
)
val view: View = b.datePicker
val cancelButton = view.findViewById<TextView>(R.id.cancel_action)
val okButton = view.findViewById<TextView>(R.id.ok_action)
cancelButton.setOnClickListener {
b.dismiss()
birthYearTIET.text = null
}
okButton.setOnClickListener {
b.dismiss()
birthYearTIET.setText((Calendar.getInstance().get(Calendar.YEAR) - Constants.MIN_AGE).toString())
}
Got the answer and working fine
val b = MonthPickerDialog.Builder(context, MonthPickerDialog.OnDateSetListener { _, _ -> // on date set } }, today.get(Calendar.YEAR), today.get(Calendar.MONTH) ) val view: View = b.datePicker val cancelButton = view.findViewById<TextView>(R.id.cancel_action) val okButton = view.findViewById<TextView>(R.id.ok_action) cancelButton.setOnClickListener { b.dismiss() birthYearTIET.text = null } okButton.setOnClickListener { b.dismiss() birthYearTIET.setText((Calendar.getInstance().get(Calendar.YEAR) - Constants.MIN_AGE).toString()) }
Thanks
I am unable to get OK button event and cancel button event. I need to listen those button event do some action kindly help me ?