当前位置: 首页>>代码示例>>Java>>正文


Java CalendarView.setSelectedDateVerticalBar方法代码示例

本文整理汇总了Java中android.widget.CalendarView.setSelectedDateVerticalBar方法的典型用法代码示例。如果您正苦于以下问题:Java CalendarView.setSelectedDateVerticalBar方法的具体用法?Java CalendarView.setSelectedDateVerticalBar怎么用?Java CalendarView.setSelectedDateVerticalBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.CalendarView的用法示例。


在下文中一共展示了CalendarView.setSelectedDateVerticalBar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeCalendar

import android.widget.CalendarView; //导入方法依赖的package包/类
public void initializeCalendar() {
  calendar = (CalendarView) findViewById(R.id.calendar);

  // sets whether to show the week number.
  calendar.setShowWeekNumber(false);

  // sets the first day of week according to Calendar.
  // here we set Monday as the first day of the Calendar
  calendar.setFirstDayOfWeek(2);


  //The background color for the selected week.
  calendar.setSelectedWeekBackgroundColor(getResources().getColor(R.color.green));

  //sets the color for the dates of an unfocused month.
  calendar.setUnfocusedMonthDateColor(getResources().getColor(R.color.transparent));

  //sets the color for the separator line between weeks.
  calendar.setWeekSeparatorLineColor(getResources().getColor(R.color.transparent));

  //sets the color for the vertical bar shown at the beginning and at the end of the selected date.
  calendar.setSelectedDateVerticalBar(R.color.darkgreen);

  //sets the listener to be notified upon selected date change.
  calendar.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

    //show the selected date as a toast
    @Override
    public void onSelectedDayChange(CalendarView view, int year, int month, int day) {
      Toast.makeText(getApplicationContext(), day + "/" + month + "/" + year, Toast.LENGTH_LONG).show();
    }
  });
}
 
开发者ID:spicecoder,项目名称:WeMeet,代码行数:34,代码来源:FirstActivity.java

示例2: initializeCalendar

import android.widget.CalendarView; //导入方法依赖的package包/类
public void initializeCalendar() {
    calendar = (CalendarView) findViewById(R.id.calendar);

    // sets whether to show the week number.
    calendar.setShowWeekNumber(false);

    // sets the first day of week according to Calendar.
    // here we set Sunday as the first day of the Calendar
    calendar.setFirstDayOfWeek(1);

    //The background color for the selected week.
    calendar.setSelectedWeekBackgroundColor(getResources().getColor(R.color.light_yellow));

    //sets the color for the dates of an unfocused month.
    calendar.setUnfocusedMonthDateColor(getResources().getColor(R.color.transparent));

    //sets the color for the separator line between weeks.
    calendar.setWeekSeparatorLineColor(getResources().getColor(R.color.transparent));

    //sets the color for the vertical bar shown at the beginning and at the end of the selected date.
    calendar.setSelectedDateVerticalBar(R.color.light_yellow);
    calendar.setClickable(true);
    /*
    calendar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("Info", "CLICKCKCKC");
            Date date = new Date(calendar.getDate());
            java.util.Calendar cal = java.util.Calendar.getInstance();
            cal.setTime(date);
            int day = cal.get(java.util.Calendar.DAY_OF_MONTH);
            int month = cal.get(java.util.Calendar.MONTH);
            int year = cal.get(java.util.Calendar.YEAR);
            Toast.makeText(getApplicationContext(), day + "/" + month + "/" + year, Toast.LENGTH_LONG).show();
            Intent intent = new Intent("com.thunderpanther.panther.DayViewActivity");
            if(taskSelected == true) {
                intent.putExtra("id", selectedTask.id);
                intent.putExtra("name", selectedTask.name);
                intent.putExtra("depth", selectedTask.depth);
                Log.d("cal", "taskSelected: " + selectedTask.name);
                selectedTask = null;
                taskSelected = false;

            } else {
                intent.putExtra("id", -1);
            }
            intent.putExtra("year", year);
            intent.putExtra("month", month);
            intent.putExtra("day", day);

            startActivity(intent);
        }
    });
    */

    //sets the listener to be notified upon selected date change.
    calendar.setOnDateChangeListener(new OnDateChangeListener() {
        //show the selected date as a toast
        @Override
        public void onSelectedDayChange(CalendarView view, int year, int month, int day) {
            Toast.makeText(getApplicationContext(), day + "/" + month + "/" + year, Toast.LENGTH_LONG).show();
            Intent intent = new Intent("com.thunderpanther.panther.DayViewActivity");
            if(taskSelected == true) {
                intent.putExtra("id", selectedTask.id);
                intent.putExtra("name", selectedTask.name);
                intent.putExtra("depth", selectedTask.depth);
                Log.d("cal", "taskSelected: " + selectedTask.name);
                selectedTask = null;
                taskSelected = false;

            } else {
                intent.putExtra("id", -1);
            }
            intent.putExtra("year", year);
            intent.putExtra("month", month);
            intent.putExtra("day", day);

            startActivity(intent);
        }
    });
}
 
开发者ID:ThunderPanther,项目名称:panther,代码行数:82,代码来源:CalendarActivity.java


注:本文中的android.widget.CalendarView.setSelectedDateVerticalBar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。