首页 > 移动平台 > 详细

安卓学习第27课——calendarView

时间:2014-09-13 14:36:35      阅读:258      评论:0      收藏:0      [点我收藏+]
<LinearLayout 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"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="选择您的生日" />

    <CalendarView
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:firstDayOfWeek="3"
        android:shownWeekCount="4"
        android:selectedWeekBackgroundColor="#aff"
        android:weekSeparatorLineColor="#ff0"
        android:unfocusedMonthDateColor="#f9f" />

</LinearLayout>
package com.example.canlendarview;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CalendarView;
import android.widget.CalendarView.OnDateChangeListener;
import android.widget.Toast;

public class MainActivity extends Activity {
    CalendarView cv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        cv=(CalendarView) findViewById(R.id.calendarView);
        cv.setOnDateChangeListener(new OnDateChangeListener(){

            @Override
            public void onSelectedDayChange(CalendarView view, int year,
                    int month, int dayOfMonth) {
                Toast.makeText(MainActivity.this, "你的生日是"+year+"年"+month+"月"+dayOfMonth+"日", Toast.LENGTH_SHORT).show();
            }
            }
        );
    }

    
}

 

安卓学习第27课——calendarView

原文:http://www.cnblogs.com/Yvettey-me/p/3969778.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!