Android open source time selection control

Android open source time selection control

Source code introduction

A powerful time selection control

Source code running screenshot

Code snippet:

  1. @Override  
  2. public   void onClick(View v) {
  3. // TODO Auto-generated method stub  
  4.   
  5. final CalendarPickerView dialogView = (CalendarPickerView) getLayoutInflater()
  6. .inflate(R.layout.dialog, null , false );
  7. if (text.getText().toString().equals( "" )) {
  8. dialogView.init( new Date(), month.getTime())
  9. .withSelectedDate( new Date());
  10. } else {
  11. Date date = DateUtils.getDate(text.getText().toString(),
  12. "yyyy-MM-dd" );
  13. dialogView.init( new Date(), month.getTime())
  14. .withSelectedDate(date);
  15. }
  16.   
  17. new AlertDialog.Builder(MainActivity. this )
  18. .setTitle( "Time Selection Control" )
  19. .setView(dialogView)
  20. .setNeutralButton( "Return" ,
  21. new DialogInterface.OnClickListener() {
  22. @Override  
  23. public   void onClick(
  24. DialogInterface dialogInterface,
  25. int i) {
  26. dialogInterface.dismiss();
  27. }
  28. })
  29. .setPositiveButton( "OK" ,
  30. new DialogInterface.OnClickListener() {
  31. @Override  
  32. public   void onClick(
  33. DialogInterface dialogInterface,
  34. int i) {
  35. long sd = dialogView.getSelectedDate()
  36. .getTime();
  37. Date dat = new Date(sd);
  38. GregorianCalendar gc = new GregorianCalendar();
  39. gc.setTime(dat);
  40. java.text.SimpleDateFormat format = new java.text.SimpleDateFormat(
  41. "yyyy-MM-dd" );
  42. String sb = format.format(gc.getTime());
  43. text.setText(sb);
  44. dialogInterface.dismiss();
  45. }
  46. }).create().show();
  47. }

Source code link: http://download..com/data/1968738

<<:  Cool elastic menu, with horizontal and arc

>>:  Realize various gesture operations for visualization

Recommend

Microsoft hints at further integration between Windows 11 and Android

In a new job listing, Microsoft has confirmed tha...

No product differentiation? Teach you 4 ways to express yourself!

Previously, whenever we talked about business and...

Who is the baby? The correct way to calculate the dog's age

Dogs are man’s best friends. We often say that on...

World Dry Season Day丨What is the tormenting "Sjögren's syndrome"?

When it comes to Sjögren's syndrome, many peo...

Airbnb’s Growth Case Study

Airbnb, Chinese name:爱Airbnb , is a service websi...

Nowadays, people eat sea cucumbers when they have a disagreement...

The reason why I put up the high-energy warning p...

How to design a commercial poster? Share 4 tips!

How to quickly master the ability to plan a comme...

User experience requires more than just methods, it also requires strategies

The rapid development of the Internet has created...

Ant Eight-Handed King Three Courses - Prop Ball, Graphics, Body

Ant Eight-Handed King Three Courses - Prop Ball, ...

Is Intel to blame for MacBook Pro's interface and memory limitations?

Intel processors have been identified as the caus...

Unreal Engine UDK official video tutorial

Unreal Engine UDK official video tutorial resourc...