1 package com.example.nanchen.mydateviewdemo; android.os.Bundle; 4 import android.support.v7.app.AppCompatActivity; 5 import android.widget.Toast; com.example.nanchen.mydateviewdemo.view.CalendarView; 8 import com.example.nanchen.mydateviewdemo.view.CalendarView.OnCalendarViewListener; java.text.SimpleDateFormat; 11 import java.util.ArrayList; 12 import java.util.Date; 13 import java.util.List; 14 import java.util.Locale; MainActivity extends AppCompatActivity { 17 18 @Override onCreate(Bundle savedInstanceState) { 20 super.onCreate(savedInstanceState); 21 setContentView(R.layout.activity_main); CalendarView calendarView = (CalendarView) findViewById(R.id.calender); List<Date> markDates = new ArrayList<>(); 27 markDates.add(new Date()); 28 calendarView.setMarkDates(markDates); calendarView.setOnCalendarViewListener(new OnCalendarViewListener() { 32 33 @Override onCalendarItemClick(CalendarView view, Date date) { 35 final SimpleDateFormat format = new SimpleDateFormat("yyyyÄêMMÔÂddÈÕ", Locale.CHINA); 36 Toast.makeText(MainActivity.this, format.format(date), Toast.LENGTH_SHORT).show(); 37 } 38 }); 39 } 40 }
12£©²¼¾ÖÎļþ
¡¡