android 中的 日历控件

android 中的日历控件_第1张图片

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity" >     <!--   api  11  -->    <CalendarView        android:id="@+id/calendarView"          android:layout_width="match_parent"          android:layout_height="match_parent" />          </RelativeLayout>

public class MainActivity extends Activity {     @Override      public void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);                  /**          long getDate();  //获取从1970年,1月1日,0点0分0秒到现在的毫秒数        int getFirstDayOfWeek();  //获取当天是本周的第几天,比如Calendar.Monday为星期一,定义值为2。                 long getMaxDate();  //获取CalendarView支持1970年到那天的最大天数               long getMinDate();  //获取CalendarView支持1970年到那天的最小天数              boolean getShowWeekNumber();  //获取是否显示星期号         public void setDate(long date, boolean animate, boolean center); //设置选择日期到1970年的描述        void setDate(long date); //设置选择的日期描述到1970年        void setFirstDayOfWeek(int firstDayOfWeek);  //设置本周起始天数                 **/                /**    android 3.0以上才有  */        CalendarView calendarView = (CalendarView) findViewById(R.id.calendarView);          calendarView.setOnDateChangeListener(new OnDateChangeListener() {              @Override              public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {                             String date = year + "年" + (month+ 1) + "月" + dayOfMonth +"日";                  Toast.makeText(MainActivity.this, date, Toast.LENGTH_SHORT).show();              }          });           }  } 

当然这个控件时 android 3.0以上才提供的,

如果3.0以下需要用到的话就需要别的 第三方开发的控件了。这里没什么说的,可以自己搜一搜。我这里上传几个(里面有很多实用的自定义日历)

下载地址:http://download.csdn.net/detail/kongbaidepao/6638669


下载地址里面都是我手机的一些 自定的日历,效果还都挺不错的。

再推荐1个开源项目

https://github.com/square/android-times-square

效果也是很不错的

贴2张效果图

android 中的日历控件_第2张图片



更多相关文章

  1. android创建自定义控件
  2. Android入门学习七:基本控件学习
  3. android之Spinner控件用法
  4. Android控件及API说明(三)
  5. 线性布局控件间的布局设置
  6. Android EditText控件
  7. android中的Selector的用法---主要是改变ListView和Button控件的
  8. Android里面各种控件的状态选择器
  9. android 控件学习笔记 --------ViewPager

随机推荐

  1. Android(安卓)有时环信初始化失败,创建app
  2. android studio的一些错误问题
  3. AS:Android数据回传(简单实例源代码)
  4. Android轮播广告条NoticeView
  5. android_camera_003
  6. Android(安卓)获取音频焦点工具类
  7. pytorch模型转ncnn,并移植android
  8. android ScrollView和ListView固定底部
  9. Web integration
  10. Java HttpClient 的简单应用