kizitonwose / Calendar

A highly customizable calendar view and compose library for Android and Kotlin Multiplatform.
MIT License
4.64k stars 503 forks source link

Does it support selecting months in the calendar? #574

Closed JamesGZM closed 5 hours ago

JamesGZM commented 1 month ago

Feature

Does it support selecting months in the calendar? I checked the API and there is no content that can be set to click on the month separately

Tech (if applicable)

I use it in Android XML

kizitonwose commented 1 month ago

You can create a monthViewClass and set a click listener on that view.

JamesGZM commented 1 month ago

You can create a monthViewClass and set a click listener on that view.

I tried using this feature, but I am confused. How do I know which month I clicked on?

JamesGZM commented 1 month ago

class YearMonthView @Keep constructor(context: Context) : FrameLayout(context) {

    init {
        setOnClickListener {
            val monthTv: TextView? = findViewById(R.id.month_tv)
            toast(monthTv?.text ?: "")
            LogUtils.e(monthTv?.tag)
        }
    }
}

I am currently setting the view tag in the bind of the monthly HeaderBinder

kizitonwose commented 1 month ago

You can set the tag or keep a field in the view that you update in the bind