From dc9b0a080f4c9536eb6f959e6a7c1394ad212f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Tue, 9 Jul 2024 10:41:17 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3,=20=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=88=E3=83=AB=E3=82=92=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/common/CommonHomeFragment.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/feature/common/src/main/java/one/nem/kidshift/feature/common/CommonHomeFragment.java b/feature/common/src/main/java/one/nem/kidshift/feature/common/CommonHomeFragment.java index b46ce2b..ada4c86 100644 --- a/feature/common/src/main/java/one/nem/kidshift/feature/common/CommonHomeFragment.java +++ b/feature/common/src/main/java/one/nem/kidshift/feature/common/CommonHomeFragment.java @@ -12,6 +12,9 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.TextView; import android.widget.Toast; import com.github.sundeepk.compactcalendarview.CompactCalendarView; @@ -63,6 +66,9 @@ public class CommonHomeFragment extends Fragment { CompactCalendarView compactCalendarView; SwipeRefreshLayout swipeRefreshLayout; TaskListItemAdapter taskListItemAdapter; + TextView calendarTitleTextView; + ImageButton calendarPrevButton; + ImageButton calendarNextButton; public CommonHomeFragment() { // Required empty public constructor @@ -122,6 +128,10 @@ public class CommonHomeFragment extends Fragment { swipeRefreshLayout = view.findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(this::updateData); + calendarTitleTextView = view.findViewById(R.id.calendarTitleTextView); + calendarPrevButton = view.findViewById(R.id.calendarPrevButton); + calendarNextButton = view.findViewById(R.id.calendarNextButton); + initCalender(); return view; @@ -266,9 +276,18 @@ public class CommonHomeFragment extends Fragment { @Override public void onMonthScroll(Date date) { - // Do nothing + // 0000年00月の形式に変換 getYear/getMonthは非推奨 + calendarTitleTextView.setText(String.format("%d年%d月", date.getYear() + 1900, date.getMonth() + 1)); } }); + + calendarPrevButton.setOnClickListener(v -> { + compactCalendarView.scrollLeft(); + }); + + calendarNextButton.setOnClickListener(v -> { + compactCalendarView.scrollRight(); + }); } /**