This commit is contained in:
KJG
2024-11-29 17:52:58 +09:00
parent 29d47c1162
commit fb444ee292
9 changed files with 227 additions and 72 deletions
@@ -3,35 +3,34 @@ package com.example.accountbook.calendar2.example
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.children
import com.example.accountbook.R
import com.example.accountbook.calendar2.CalendarLayoutListener
import com.example.accountbook.calendar2.CalendarManager
import com.example.accountbook.calendar2.CalendarPagerAdapter
import com.example.accountbook.databinding.CalendarActivityExampleBinding
import com.example.accountbook.databinding.ExDayViewBinding
import com.example.calrendarview.DayView
import com.example.calrendarview.model.CalendarBean
import com.example.calrendarview.model.CalendarFactory
import com.example.calrendarview.model.DayInfo
class ActivityCalendarEx: AppCompatActivity() {
// member
private var bind: CalendarActivityExampleBinding? = null
lateinit var bind: CalendarActivityExampleBinding
// AppCompatActivity
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
bind = CalendarActivityExampleBinding.inflate(this.layoutInflater)
bind?.let {
setContentView(it.root)
it.calendarLayoutEx.listener = object: CalendarLayoutListener {
override fun onCreatedViewPager() {
it.calendarLayoutEx.viewPager?.adapter = CalendarPagerAdapter(this@ActivityCalendarEx).apply {
this.layoutId = R.layout.calendar_pager_example
}
}
}
it.root.setOnClickListener{
}
}
// for (i in 0 until 7) {
val infos = CalendarFactory().getBeansOfThisWeek()
bind.otherViews.numberOfRow = 7
// (bind.otherViews.getChildAt(i) as? DayView)?.dayInfo = infos.get(i)
// }
setContentView(bind.root)
}
override fun onStart() {
@@ -3,62 +3,68 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/otherViewEx"
android:background="#eeeeee"
<com.example.calrendarview.MonthView
android:id="@+id/otherViews"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:text="otherView"
android:gravity="center"
app:item_layout="@layout/ex_day_view"
app:numOfDayId="@id/ex_text_day"
/>
<com.example.accountbook.calendar2.CalendarLayout
android:id="@+id/calendarLayoutEx"
android:background="#dddddd"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/otherViewEx"
app:layout_constraintBottom_toBottomOf="parent"
>
<!-- app:calendarId="@id/calendarViewPager"-->
<!-- <com.example.accountbook.calendar2.CalendarLayout-->
<!-- android:id="@+id/calendarLayoutEx"-->
<!-- android:background="#dddddd"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- app:layout_constraintTop_toBottomOf="@id/otherViewEx"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- >-->
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/test1"
android:background="#9acd32"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/test2"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintTop_toTopOf="parent"
>
<TextView
android:background="#a8a800"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="test"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- <TextView-->
<!-- android:id="@+id/subViewEx"-->
<!--&lt;!&ndash; app:calendarId="@id/calendarViewPager"&ndash;&gt;-->
<!--&lt;!&ndash; >&ndash;&gt;-->
<!-- <androidx.viewpager2.widget.ViewPager2-->
<!-- android:id="@+id/test1"-->
<!-- android:background="#9acd32"-->
<!-- android:layout_width="match_parent"-->
<!-- android:background="@color/material_dynamic_primary50"-->
<!-- android:layout_height="30dp"-->
<!-- android:layout_height="match_parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- android:text="subView"-->
<!-- android:gravity="center"-->
<!-- />-->
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/calendar"-->
<!-- android:background="#cccccc"-->
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/test2"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- app:layout_constraintTop_toBottomOf="@id/subViewEx"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- />-->
</com.example.accountbook.calendar2.CalendarLayout>
<!-- android:layout_height="50dp"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- >-->
<!-- <TextView-->
<!-- android:background="#a8a800"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="30dp"-->
<!-- android:text="test"-->
<!-- android:gravity="center"-->
<!-- app:layout_constraintTop_toTopOf="parent"/>-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<!--&lt;!&ndash; <TextView&ndash;&gt;-->
<!--&lt;!&ndash; android:id="@+id/subViewEx"&ndash;&gt;-->
<!--&lt;!&ndash; android:layout_width="match_parent"&ndash;&gt;-->
<!--&lt;!&ndash; android:background="@color/material_dynamic_primary50"&ndash;&gt;-->
<!--&lt;!&ndash; android:layout_height="30dp"&ndash;&gt;-->
<!--&lt;!&ndash; app:layout_constraintTop_toTopOf="parent"&ndash;&gt;-->
<!--&lt;!&ndash; android:text="subView"&ndash;&gt;-->
<!--&lt;!&ndash; android:gravity="center"&ndash;&gt;-->
<!--&lt;!&ndash; />&ndash;&gt;-->
<!--&lt;!&ndash; <androidx.recyclerview.widget.RecyclerView&ndash;&gt;-->
<!--&lt;!&ndash; android:id="@+id/calendar"&ndash;&gt;-->
<!--&lt;!&ndash; android:background="#cccccc"&ndash;&gt;-->
<!--&lt;!&ndash; android:layout_width="match_parent"&ndash;&gt;-->
<!--&lt;!&ndash; android:layout_height="0dp"&ndash;&gt;-->
<!--&lt;!&ndash; app:layout_constraintTop_toBottomOf="@id/subViewEx"&ndash;&gt;-->
<!--&lt;!&ndash; app:layout_constraintBottom_toBottomOf="parent"&ndash;&gt;-->
<!--&lt;!&ndash; />&ndash;&gt;-->
<!-- </com.example.accountbook.calendar2.CalendarLayout>-->
<!-- <com.example.calrendarview.DayView-->
<!-- android:id="@+id/test"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:item_layout="@layout/activity_writer"-->
<!-- app:numOfDayId="@id/text_write_title"/>-->
</androidx.constraintlayout.widget.ConstraintLayout>
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingVertical="10dp"
android:paddingHorizontal="5dp"
>
<TextView
android:id="@+id/ex_text_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:gravity="end|center_vertical"
android:text="01일"
android:textSize="15dp"
/>
<TextView
android:id="@+id/ex_text_day_view_01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/ex_text_day"
android:gravity="end|center_vertical"
android:text="ex_text_day"
android:textSize="12dp"
android:background="#9acd32"
android:layout_marginTop="5dp"
/>
<TextView
android:id="@+id/ex_text_day_view_02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/ex_text_day_view_01"
android:gravity="end|center_vertical"
android:text="ex_text_day"
android:textSize="12dp"
android:background="#dda0dd"
android:layout_marginTop="5dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>