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


Java CalendarView.setFirstDayOfWeek方法代码示例

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


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

示例1: onClick

import android.widget.CalendarView; //导入方法依赖的package包/类
public void onClick(View v) {
    DatePickerDialog dpd = new DatePickerDialog(
            mActivity, new DateListener(v), mTime.year, mTime.month, mTime.monthDay);
    CalendarView cv = dpd.getDatePicker().getCalendarView();
    cv.setShowWeekNumber(Utils.getShowWeekNumber(mActivity));
    int startOfWeek = Utils.getFirstDayOfWeek(mActivity);
    // Utils returns Time days while CalendarView wants Calendar days
    if (startOfWeek == Time.SATURDAY) {
        startOfWeek = Calendar.SATURDAY;
    } else if (startOfWeek == Time.SUNDAY) {
        startOfWeek = Calendar.SUNDAY;
    } else {
        startOfWeek = Calendar.MONDAY;
    }
    cv.setFirstDayOfWeek(startOfWeek);
    dpd.setCanceledOnTouchOutside(true);
    dpd.show();
}
 
开发者ID:x7hub,项目名称:Calendar_lunar,代码行数:19,代码来源:EditEventView.java

示例2: initializeCalendar

import android.widget.CalendarView; //导入方法依赖的package包/类
private void initializeCalendar() {
    calendar = (CalendarView) findViewById(R.id.calendar);
    calendar.setFirstDayOfWeek(1); //SUNDAY
    calendar.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int day) {
            navigateToDate(year, month, day);
        }
    });
}
 
开发者ID:cache117,项目名称:social-journal,代码行数:11,代码来源:JournalCalendar.java

示例3: 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

示例4: mostrarEventos

import android.widget.CalendarView; //导入方法依赖的package包/类
@SuppressLint({"NewApi","ResourceAsColor"})
private void mostrarEventos(){
	calendario=(CalendarView) findViewById(R.id.calendario_eventos);
	calendario.setFirstDayOfWeek(Calendar.MONDAY); //Hacemos que el primer d�a de la semana sea Lunes
	calendario.setShowWeekNumber(false); //Ocultamos el n�mero de la semana
	
	//Obtenemos la resoluci�n de pantalla y cambiamos la altura del calendario si fuera necesario
	DisplayMetrics sizeScreen=new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(sizeScreen);
	int altoPantalla=sizeScreen.heightPixels;
	
	if(altoPantalla<800){ //Comprueba que la pantalla sea menor a 800p de altura
		//800 es el tama�o de la pantalla de desarrollo con margenes
		int altoCalendario=800-altoPantalla; //Obtenemos la diferencia del tama�o de la pantalla actual
		altoCalendario=640-altoCalendario; //Obtenemos la nueva altura del calendario
		
		//Hacemos que la altura cuadre con la resoluci�n de nuestro dispositivo
		LinearLayout.LayoutParams propiedades=(LinearLayout.LayoutParams) calendario.getLayoutParams();
		propiedades.height=altoCalendario;
		calendario.setLayoutParams(propiedades);
	}
	
	//Declaramos la variables que har�n de botones
	botonAgregarEntrenamiento=findViewById(R.id.boton_agregar_entrenamiento);
	botonVerEntrenamiento=findViewById(R.id.boton_ver_entrenamiento);
	botonEditarEntrenamiento=findViewById(R.id.boton_editar_entrenamiento);
	botonBorrarEntrenamiento=findViewById(R.id.boton_borrar_entrenamiento);
	botonAgregarPartido=findViewById(R.id.boton_agregar_partido);
	botonVerPartido=findViewById(R.id.boton_ver_partido);
	botonEditarPartido=findViewById(R.id.boton_editar_partido);
	botonBorrarPartido=findViewById(R.id.boton_borrar_partido);
	
	//Declaramos las imagenes que haran a funci�n de herramientas para los eventos
	agregarEventoEntrenamiento=(ImageView) findViewById(R.id.agregar_evento_entrenamiento);
	verEstadisticasEntrenamiento=(ImageView) findViewById(R.id.ver_estadisticas_entrenamiento);
	editarEventoEntrenamiento=(ImageView) findViewById(R.id.editar_evento_entrenamiento);
	borrarEventoEntrenamiento=(ImageView) findViewById(R.id.borrar_evento_entrenamiento);
	agregarEventoPartido=(ImageView) findViewById(R.id.agregar_evento_partido);
	verEstadisticasPartido=(ImageView) findViewById(R.id.ver_estadisticas_partido);
	editarEventoPartido=(ImageView) findViewById(R.id.editar_evento_partido);
	borrarEventoPartido=(ImageView) findViewById(R.id.borrar_evento_partido);
	
	//Registramos los controles de borrar como men�s contextuales
	registerForContextMenu(borrarEventoEntrenamiento);
	registerForContextMenu(borrarEventoPartido);
	
	fechaActual=getFechaActual(); //Fecha actual
	fechaSeleccionada=fechaActual; //Igualamos la fecha actual a la fecha seleccionada
	
	accionesMostrarEventos(fechaSeleccionada); //Imagenes desactivadas y activadas
	
	accionesHerramientasEventos(); //Acciones de las imagenes
	
	calendario.setOnDateChangeListener(new OnDateChangeListener(){
		@Override
		public void onSelectedDayChange(CalendarView arg, int year, int mes, int dia){
			mes=mes+1; //Le debemos sumar 1 al mes porque va solo del 0 al 11
			String month="0";
			if(mes<10){ //Si el mes es fechaInferior a 2 cifras, le agregamos un 0 delante para mantener el formato
				month=month.concat(String.valueOf(mes));
			}else{
				month=String.valueOf(mes);
			}
			
			String day="0";
			if(dia<10){
				day=day.concat(String.valueOf(dia));
			}else{
				day=String.valueOf(dia);
			}
			
			fechaSeleccionada=year+"-"+month+"-"+day;
			accionesMostrarEventos(fechaSeleccionada);
		}
	});
}
 
开发者ID:DAM2-GOW,项目名称:FCM,代码行数:77,代码来源:PaginaCalendario.java

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