Another super-beautiful calendar Control for Android, android calendar Control
※Effect
※Usage
Package com. fancyy. calendarweight; import java. util. arrayList; import java. util. list; import android. app. activity; import android. content. context; import android. graphics. drawable. bitmapDrawable; import android. OS. bundle; import android. view. gravity; import android. view. view; import android. view. view. onClickListener; import android. view. viewGroup. layoutParams; import android. view. animation. animationUtils; impo Rt android. widget. button; import android. widget. linearLayout; import android. widget. popupWindow; import android. widget. relativeLayout; import android. widget. textView; import com. fancyy. calendarweight. KCalendar. onCalendarClickListener; import com. fancyy. calendarweight. KCalendar. onCalendarDateChangedListener; public class MainActivity extends Activity {String date = null; // set the default date format to "" Standard DAT Egex Button bt; protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); bt = (Button) findViewById (R. id. bt); bt. setOnClickListener (new OnClickListener () {public void onClick (View v) {new PopupWindows (MainActivity. this, bt) ;}}) ;}public class PopupWindows extends PopupWindow {public PopupWindows (Context mContext, View parent) {View v Iew = View. inflate (mContext, R. layout. popupwindow_calendar, null); view. startAnimation (AnimationUtils. loadAnimation (mContext, R. anim. fade_in); LinearLayout ll_popup = (LinearLayout) view. findViewById (R. id. ll_popup); ll_popup.startAnimation (AnimationUtils. loadAnimation (mContext, R. anim. push_bottom_in_1); setWidth (LayoutParams. FILL_PARENT); setHeight (LayoutParams. FILL_PARENT); setBackgroundDrawable (new Bit MapDrawable (); setFocusable (true); setOutsideTouchable (true); setContentView (view); showAtLocation (parent, Gravity. BOTTOM, 0, 0); update (); final TextView popupwindow_calendar_month = (TextView) view. findViewById (R. id. popupwindow_calendar_month); final KCalendar calendar = (KCalendar) view. findViewById (R. id. popupwindow_calendar); Button popupwindow_calendar_bt_enter = (Button) view. findViewById (R. id. popu Pwindow_calendar_bt_enter); popupwindow_calendar_month.setText (calendar. getCalendarYear () + "year" + calendar. getCalendarMonth () + "month"); if (null! = Date) {int years = Integer. parseInt (date. substring (0, date. indexOf ("-"); int month = Integer. parseInt (date. substring (date. indexOf ("-") + 1, date. lastIndexOf ("-"); popupwindow_calendar_month.setText (years + "year" + month + "month"); calendar. showCalendar (years, month); calendar. setCalendarDayBgColor (date, R. drawable. calendar_date_focused);} List <String> list = new ArrayList <String> (); // sets the tag list. add ("2014-04-01"); list. add ("2014-04-02"); calendar. addMarks (list, 0); // listen to the selected date calendar. setOnCalendarClickListener (new OnCalendarClickListener () {public void onCalendarClick (int row, int col, String dateFormat) {int month = Integer. parseInt (dateFormat. substring (dateFormat. indexOf ("-") + 1, dateFormat. lastIndexOf ("-"); if (calendar. getCalendarMonth ()-month = 1 // cross-year jump | calendar. getCalendarMonth ()-month =-11) {calendar. lastMonth ();} else if (month-calendar. getCalendarMonth () = 1 // cross-year jump | month-calendar. getCalendarMonth () =-11) {calendar. nextMonth ();} else {calendar ar. removeAllBgColor (); calendar. setCalendarDayBgColor (dateFormat, R. drawable. calendar_date_focused); date = dateFormat; // returns the last value to the global date }}); // listens to the calendar of the current month. setOnCalendarDateChangedListener (new OnCalendarDateChangedListener () {public void onCalendarDateChanged (int year, int month) {popupwindow_calendar_month.setText (year + "year" + month + "month ");}}); // last month's listening button RelativeLayout popupwindow_calendar_last_month = (RelativeLayout) view. findViewById (R. id. popupwindow_calendar_last_month); popupwindow_calendar_last_month.setOnClickListener (new OnClickListener () {public void onClick (View v) {calendar ar. lastMonth () ;}}); // click RelativeLayout popupwindow_calendar_next_month = (RelativeLayout) view next month. findViewById (R. id. popupwindow_calendar_next_month); popupwindow_calendar_next_month.setOnClickListener (new OnClickListener () {public void onClick (View v) {calendar ar. nextMonth () ;}}); // close the window popupwindow_calendar_bt_enter.setOnClickListener (new OnClickListener () {public void onClick (View v) {dismiss ();}});}}}
※Demo download http://download.csdn.net/detail/u010785585/7667921
How does android set events for each date button of the 30 built-in calendar control calendarview, such as redirection?
CalendarView cv = (CalendarView) findViewById (R. id. calendarView1 );
Cv. setOnDateChangeListener (new OnDateChangeListener (){
Publicvoid onSelectedDayChange (CalendarView view, int year, int month, int dayOfMonth ){
Toast. makeText (MainActivity. this, "onSelectedDayChange", Toast. LENGTH_LONG). show ();
}
});
Recommended calendar for Android
The Chinese Perpetual calendar, 365 calendar, and moji.com are the most popular.