Another super-beautiful calendar Control for Android

Source: Internet
Author: User
Tags dateformat

Another super-beautiful calendar Control for Android
※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
 
  
List = new ArrayList
  
   
(); // Set 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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.