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


Java CalendarView.setOnDateChangeListener方法代码示例

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


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

示例1: onCreate

import android.widget.CalendarView; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.duedate_chooser);

    TextView courseSelected = (TextView) findViewById(R.id.selectedCourse);

    if(getIntent().hasExtra("coursePos")){
        coursePos = getIntent().getIntExtra("coursePos", -1);
        if(coursePos < 0){ Log.d("Sean", "Invalid Course Pos"); }
    }
    else{
        coursePos = -1;
    }
    if(coursePos >= 0){
        courseSelected.setText("Course: " + User.currentUser.getCourses()[coursePos]);
    }
    else{
        courseSelected.setText("Course: ");
    }

    CalendarView calendarView = (CalendarView) findViewById(R.id.calendarview);
    startDate = calendarView.getDate();
    calendarView.setOnDateChangeListener(dateChangeListener);
}
 
开发者ID:aarya123,项目名称:ToDoList252,代码行数:25,代码来源:DueDateChooserActivity.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: onCreate

import android.widget.CalendarView; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.kursbucheintrag);
    vkurs = (TextView) findViewById(R.id.textViewkurs);
    vthema = (EditText) findViewById(R.id.editTextthema);
    vhausaufgabe = (EditText) findViewById(R.id.editTextha);
    vdoppelstunde = (Button) findViewById(R.id.buttonds);
    vspeichern = (Button) findViewById(R.id.buttonspeichern);
    vliste = (Button) findViewById(R.id.buttonliste);
    // vdatum = (DatePicker) findViewById(R.id.datePicker);
    Calendar myCal2 = new GregorianCalendar();
    pjahr = myCal2.get( Calendar.YEAR  );
    pmonat = myCal2.get( Calendar.MONTH );
    ptag = myCal2.get( Calendar.DATE  );
    CalendarView calendarView=(CalendarView) findViewById(R.id.calendarView);

    calendarView.setOnDateChangeListener(new OnDateChangeListener() {
                                             @Override
                                             public void onSelectedDayChange(CalendarView view, int year, int month,
                                                                             int dayOfMonth) {
                                                 pjahr = year;
                                                 pmonat = month;
                                                 ptag = dayOfMonth;
                                                 // Toast.makeText(getApplicationContext(), ""+dayOfMonth, 0).show();// TODO Auto-generated method stub

                                             }
                                         });
    kursnummer = getIntent().getStringExtra("pkurs");
    kursname = getIntent().getStringExtra("pkursname");
    pdatum = getIntent().getStringExtra("pdatum");
    dm = new DataManipulator(this);

    if(!pdatum.equals("")){
        calendarView.setVisibility(View.INVISIBLE);
    }

    vkurs.setText("Kurs: " + kursname);
    vspeichern.setOnClickListener(this);
    vdoppelstunde.setOnClickListener(this);
}
 
开发者ID:ngbvol,项目名称:Zensuren,代码行数:41,代码来源:kursbucheintragen.java

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

示例5: onCreate

import android.widget.CalendarView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calendar);

    final CalendarView calendarView = (CalendarView)findViewById(R.id.calendar_view);
    Intent callerIntent = getIntent();
    long currentTime = callerIntent.getLongExtra("currentTime",0);
    final long millis = TimeUtil.getMillisFromTime(currentTime);
    calendarView.setDate(millis);

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date(millis));
    final int currentYear = cal.get(Calendar.YEAR);
    final int currentMonth = cal.get(Calendar.MONTH);
    final int currentDayOfMonth = cal.get(Calendar.DAY_OF_MONTH);

    calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
            long changedMillis = view.getDate();
            if(currentYear != year || currentMonth != month || currentDayOfMonth != dayOfMonth) {
                Intent intent = new Intent(CalendarActivity.this,MainActivity.class);
                intent.putExtra("millis", changedMillis);
                setResult(RESULT_OK, intent);
                finish();
            }
        }
    });
}
 
开发者ID:UtopiaGroup,项目名称:Utopia,代码行数:31,代码来源:CalendarActivity.java

示例6: onCreate

import android.widget.CalendarView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //Load previous entries
    dbHandler = new DBHandler(this);
    _Schedule = dbHandler.getAllEvents();

    //Setup widgets for easier access
    _Calendar = (CalendarView) this.findViewById(calendarView);
    _ButtonSave = (Button) this.findViewById(R.id.button8);
    _EditText = (EditText) this.findViewById(R.id.editText);
    _SelectedDay = new Day(Calendar.getInstance().get(Calendar.YEAR),
            Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
    selectedDateChanged(_Calendar, _SelectedDay.getYear(), _SelectedDay.getMonth(), _SelectedDay.getDay());

    //Set up button
    _ButtonSave.setText(R.string.btn_edit);
    updateEditText();

    _ButtonSave.setOnClickListener(this);
    _Calendar.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
            selectedDateChanged(view, year, month, dayOfMonth);
        }

    });

    //Define bottom navigation view (thats why design library in gradle was imported)
    BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById (R.id.bottom_navigation);

    //Display right icon
    bottomNavigationView.getMenu().getItem(2).setChecked(true);

    //Define Bottom navigation view listener
    bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        //Selected icon(item) - changes to the appropriate view
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            dbHandler.saveAllEvents(_Schedule);
            switch (item.getItemId())
            {
                //Contacts
                case R.id.action_contacts:
                    startActivity(new Intent(MyCalendarActivity.this, ContactsActivity.class));
                    break;

                //Exercise
                case R.id.action_exercise:
                    startActivity(new Intent(MyCalendarActivity.this, GroupsOfExercisesActivity.class));
                    break;

                //Calendar
                case R.id.action_calendar:
                    break;

                //Settings
                case R.id.action_settings:
                    startActivity(new Intent(MyCalendarActivity.this, UserSettingsActivity.class));
                    break;
            }
            return true;
        }
    });


}
 
开发者ID:clicket7,项目名称:FiTAbs,代码行数:70,代码来源:MyCalendarActivity.java

示例7: onCreate

import android.widget.CalendarView; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.kursbucheintrag);
    eintragnummer = getIntent().getStringExtra("peid");
    vkurs = (TextView) findViewById(R.id.textViewkurs);
    vthema = (EditText) findViewById(R.id.editTextthema);
    vhausaufgabe = (EditText) findViewById(R.id.editTextha);
    vdoppelstunde = (Button) findViewById(R.id.buttonds);
    vspeichern = (Button) findViewById(R.id.buttonspeichern);
    vliste = (Button) findViewById(R.id.buttonliste);
    //vdatum = (DatePicker) findViewById(R.id.datePicker);
    CalendarView calendarView=(CalendarView) findViewById(R.id.calendarView);

    calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(CalendarView view, int year, int month,
                                        int dayOfMonth) {
            pjahr = year;
            pmonat = month;
            ptag = dayOfMonth;
            // Toast.makeText(getApplicationContext(), ""+dayOfMonth, 0).show();// TODO Auto-generated method stub

        }
    });
    dm = new DataManipulator(this);

    String[] datensatz = dm.getkursmappeneintrag(eintragnummer);

    vthema.setText(datensatz[4]);
    vhausaufgabe.setText(datensatz[5]);
    if(datensatz[3].equals("1")){
        vdoppelstunde.setText("Einzelstunde");
    }else{
        vdoppelstunde.setText("Doppelstunde");
    }


    String[]datumzerteilt = new String[4];
    datumzerteilt = datensatz[2].split("\\.");
    Calendar myCal2 = new GregorianCalendar();
    pjahr = Integer.parseInt(datumzerteilt[2]);
    pmonat = Integer.parseInt(datumzerteilt[1])-1;
    ptag = Integer.parseInt(datumzerteilt[0]);
    myCal2.set(pjahr, pmonat, ptag);
    calendarView.setDate(myCal2.getTimeInMillis());
    //vdatum.updateDate(Integer.parseInt(datumzerteilt[2]), Integer.parseInt(datumzerteilt[1])-1, Integer.parseInt(datumzerteilt[0]));


    vkurs.setText("Eintrag ändern / löschen");
    vspeichern.setOnClickListener(this);
    vdoppelstunde.setOnClickListener(this);
    vliste.setText("Eintrag löschen");
    vliste.setOnClickListener(this);

}
 
开发者ID:ngbvol,项目名称:Zensuren,代码行数:56,代码来源:kursbuchbearbeiten.java

示例8: createView

import android.widget.CalendarView; //导入方法依赖的package包/类
@Override
public CalendarView createView(Properties properties) {
  CalendarView calendarView = new CalendarView(activity);
  calendarView.setOnDateChangeListener(new OnDateChangeListener());
  return calendarView;
}
 
开发者ID:eclipsesource,项目名称:tabris-plugin-calendar,代码行数:7,代码来源:CalendarOperator.java

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

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