Documente Academic
Documente Profesional
Documente Cultură
<RelativeLayout 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"
tools:context=".MainActivity">
<CalendarView
android:id="@+id/simpleCalendarView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:firstDayOfWeek="2"
android:maxDate="01/01/2019"
android:minDate="01/01/2016" />
</RelativeLayout>
package com.example.calendar;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CalendarView;
import android.widget.Toast;
CalendarView simpleCalendarView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
simpleCalendarView = (CalendarView) findViewById(R.id.simpleCalendarView);
simpleCalendarView.setFocusedMonthDateColor(Color.RED);
simpleCalendarView.setUnfocusedMonthDateColor(Color.BLUE);
simpleCalendarView.setSelectedWeekBackgroundColor(Color.RED);
simpleCalendarView.setWeekSeparatorLineColor(Color.GREEN);
simpleCalendarView.setOnDateChangeListener(new
CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
Toast.makeText(getApplicationContext(), dayOfMonth + "/" + month +
"/" + year, Toast.LENGTH_LONG).show();
}
});
}
}
Pas 3: Rulăm aplicația și observăm rezultatul final: