本文整理汇总了Java中android.widget.CalendarView类的典型用法代码示例。如果您正苦于以下问题:Java CalendarView类的具体用法?Java CalendarView怎么用?Java CalendarView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CalendarView类属于android.widget包,在下文中一共展示了CalendarView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configuracionCalendario
import android.widget.CalendarView; //导入依赖的package包/类
private void configuracionCalendario(){
this.calendario.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
Date dateRepresentation = cal.getTime();
String dateString = dateFormat.format(dateRepresentation);
Intent intent = new Intent(getContext(), HistorialDiaConcreto.class);
intent.putExtra("dayToShow", dateString);
intent.putExtra("dayToShow2", dateFormat2.format(dateRepresentation));
startActivity(intent);
}
});
}
示例2: selectedDateChanged
import android.widget.CalendarView; //导入依赖的package包/类
/**
* Method called when CalendarView selected date changes
* @param view - current view
* @param year - year selected
* @param month - month selected
* @param dayOfMonth - day selected
*/
private void selectedDateChanged(CalendarView view, int year, int month, int dayOfMonth){
//Switch back to view mode
_ButtonSave.setText(R.string.btn_edit);
_EditText.setText("");
updateEditText();
closeOnScreenKeyboard(view);
Day selectedDay = new Day(year, month, dayOfMonth);
_SelectedDay = selectedDay;
if(dayIsAlreadyInList(selectedDay)){
int indexOfFoundDay = getIndexOfSpecificDay(selectedDay);
Day day = _Schedule.get(indexOfFoundDay);
_EditText.setText(day.getMessage());
}
}
示例3: onViewCreated
import android.widget.CalendarView; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
database=new DataBase(this.getContext());
cal_doj=getActivity().findViewById(R.id.calview_doj);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
data_date = sdf.format(new Date(cal_doj.getDate()));
cal_doj.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(@NonNull CalendarView calendarView, int year, int month, int date) {
if(month==12)
month=1;
else
month=month+1;
data_date=date + "/" + month + "/" + year;
Toast.makeText(getContext(), date + "/" + month + "/" + year , Toast.LENGTH_SHORT).show();
}
});
}
示例4: createPendingViewPostCreateProcess
import android.widget.CalendarView; //导入依赖的package包/类
@Override
public PendingViewPostCreateProcess createPendingViewPostCreateProcess(final View view, ViewGroup viewParent)
{
PendingViewPostCreateProcess pendingViewPostCreateProcess = super.createPendingViewPostCreateProcess(view, viewParent);
pendingViewPostCreateProcess.addPendingSetAttribsTask(new Runnable()
{
@Override
public void run()
{
// Esto es raro de narices pero es un workaround de un buggy de CalendarView al crearse programáticamente
// o bien es por nuestra "culpa" al aplicar los atributos en un orden incorrecto, el caso es que la semana
// actual no se selecciona, llamando a calendarView.setDate(System.currentTimeMillis()) no reacciona
// pero sí lo hace si cambiamos mucho la fecha
CalendarView calView = (CalendarView) view;
long current = System.currentTimeMillis();
calView.setDate(current - 7 * 24 * 60 * 60 * 1000);
calView.setDate(current);
//calView.setDate(current,true,true);
}
});
return pendingViewPostCreateProcess;
}
示例5: initialConfiguration
import android.widget.CalendarView; //导入依赖的package包/类
private static void initialConfiguration(TestActivity act, View rootView)
{
CalendarView calendarView = (CalendarView)rootView.findViewById(R.id.calendarViewTestId);
DatePicker datePicker = (DatePicker)rootView.findViewById(R.id.datePickerTestId);
if ("sdk".equals( Build.PRODUCT ) || "sdk_x86".equals( Build.PRODUCT ))
{
// La aceleración hardware hace caer el emulador 4.0.3 en estos componentes
// http://kevsaidwhat.blogspot.com.es/2012/09/intel-atom-emulator-crashes-with.html
calendarView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
datePicker.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
else
{
// Esto es sólo por jugar para asegurar que hay un calendarView y un datePicker en estos tests
calendarView.getLayerType();
datePicker.getLayerType();
}
defineTabHost(act,rootView);
inflateViewStub(act,rootView);
}
示例6: set
import android.widget.CalendarView; //导入依赖的package包/类
@Override
public void set(CalendarView calendarView, Properties properties) {
super.set(calendarView, properties);
for (String property : properties.getAll().keySet()) {
switch (property) {
case PROP_DATE:
calendarView.setDate(Long.parseLong(properties.getString(PROP_DATE)), true, false);
break;
case PROP_MIN_DATE:
calendarView.setMinDate(Long.parseLong(properties.getString(PROP_MIN_DATE)));
break;
case PROP_MAX_DATE:
calendarView.setMaxDate(Long.parseLong(properties.getString(PROP_MAX_DATE)));
break;
}
}
}
示例7: 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);
}
示例8: onCreateDialog
import android.widget.CalendarView; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
int year = currentDateTime.getYear();
int month = currentDateTime.getMonthOfYear();
int day = currentDateTime.getDayOfMonth();
//Joda's month indexing is +1 compared to android.
month--;
// Create a new instance of DatePickerDialog
DatePickerDialog dpdialog =
new DatePickerDialog(getActivity(), this, year, month, day);
//Get the CalendarView for the DatePicker, Hide the week numbers
CalendarView cv = dpdialog.getDatePicker().getCalendarView();
cv.setShowWeekNumber(false);
return dpdialog;
}
示例9: 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();
}
示例10: onCreateView
import android.widget.CalendarView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_historial, container, false);
this.calendario = (CalendarView) view.findViewById(R.id.calendario_historial);
configuracionCalendario();
return view;
}
示例11: 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);
}
});
}
示例12: type
import android.widget.CalendarView; //导入依赖的package包/类
public static SubjectFactory<CalendarViewSubject, CalendarView> type() {
return new SubjectFactory<CalendarViewSubject, CalendarView>() {
@Override
public CalendarViewSubject getSubject(FailureStrategy fs, CalendarView that) {
return new CalendarViewSubject(fs, that);
}
};
}
示例13: 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);
}
示例14: 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();
}
});
}
示例15: 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();
}
}
});
}