...
This commit is contained in:
parent
fb444ee292
commit
a1162f2f4c
@ -7,8 +7,10 @@ import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.size
|
||||
import com.example.calrendarview.model.CalendarFactory
|
||||
import com.example.calrendarview.model.DayInfo
|
||||
|
||||
@ -27,7 +29,6 @@ class MonthView : BaseCustomViews {
|
||||
var numberOfRow : Int = 7
|
||||
set(value) {
|
||||
field = value
|
||||
initChildViews()
|
||||
}
|
||||
|
||||
var dayInfo: DayInfo? = null
|
||||
@ -41,25 +42,48 @@ class MonthView : BaseCustomViews {
|
||||
field = value
|
||||
numOfDayView = findViewById<TextView>(field)
|
||||
}
|
||||
var itemLayout : Int = -1
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
var numOfDayView : TextView? = null
|
||||
|
||||
var mWidth: Int? = null
|
||||
var mHeight: Int? = null
|
||||
|
||||
|
||||
override fun onTypedArray(context: Context, typedArray: TypedArray) {
|
||||
super.onTypedArray(context, typedArray)
|
||||
numberOfday = typedArray.getResourceId(R.styleable.BaseCustomViews_numOfDayId, R.id.day_num)
|
||||
itemLayout = typedArray.getResourceId(R.styleable.BaseCustomViews_item_layout, R.id.day_num)
|
||||
displayDayNumber()
|
||||
}
|
||||
|
||||
fun initChildViews(): Array<DayView?> {
|
||||
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
||||
super.onLayout(changed, left, top, right, bottom)
|
||||
Log.i("MonthView >>> ","onLayout")
|
||||
initChildViews()
|
||||
}
|
||||
|
||||
fun initChildViews(): Array<View?> {
|
||||
//todo : 7 * numberOfRow 의 차일드 뷰를 만든다.
|
||||
val infos = CalendarFactory().getBeansOfThisWeek()
|
||||
val childrens = Array<DayView?>(numberOfRow) {
|
||||
val dayView = inflate(context, R.layout.item_day, this) as? DayView
|
||||
dayView?.dayInfo = infos[it]
|
||||
addView(dayView)
|
||||
val childrens = Array<View?>(numberOfRow) {i ->
|
||||
val dayView = LayoutInflater.from(context).inflate(layouId, this, false)
|
||||
val p = ViewGroup.LayoutParams(100, 100)
|
||||
Log.i("MonthView >>> ","numberOfRow ${numberOfRow}")
|
||||
dayView?.let {
|
||||
it.layoutParams = p
|
||||
Log.i("MonthView >>> ","dayView.width ${dayView.width}")
|
||||
numOfDayView?.text = infos[i].getNumOfDay().toString()
|
||||
addView(it)
|
||||
}
|
||||
return@Array dayView
|
||||
}
|
||||
Log.i("MonthView initChildViews >>> ","childrens count ${childrens.size}")
|
||||
Log.i("MonthView initChildViews >>> ","mWidth ${width}")
|
||||
Log.i("MonthView initChildViews >>> ","mHeight ${height}")
|
||||
return childrens
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ class ActivityCalendarEx: AppCompatActivity() {
|
||||
|
||||
// for (i in 0 until 7) {
|
||||
val infos = CalendarFactory().getBeansOfThisWeek()
|
||||
bind.otherViews.numberOfRow = 7
|
||||
// bind.otherViews.numberOfRow = 7
|
||||
// (bind.otherViews.getChildAt(i) as? DayView)?.dayInfo = infos.get(i)
|
||||
// }
|
||||
setContentView(bind.root)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user