当前位置:网站首页>Function and usage of calendar view component

Function and usage of calendar view component

2022-07-07 17:36:00 XLMN

calendarview Function and usage of calendar view component

calendarview Can be used to display and select dates . Users can choose the date , Or scroll the calendar by touching , Can also pass setondatechangelistener() Release method to monitor the date change

<?xml version="1.0" encoding="utf-8"?>



Set weekly style line color

public class MainActivity extends Activity {
CalendarView cv;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.calendarview);
    cv=findViewById(R.id.calendarview);
    // by calendarview Add event listener 
    cv.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
            // Use total Displays the date selected by the user 
            Toast.makeText(MainActivity.this," Do you believe a word , Those who are ready will get a candy  "+year+" year "+(month+1)+" month "+dayOfMonth+" Japan , come on. , The world is uncertain , You are the dark horse ",Toast.LENGTH_LONG).show();
        }
    });
}

}

原网站

版权声明
本文为[XLMN]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071527553736.html