Get the week day from a calendarview in android

那年仲夏 提交于 2019-12-10 22:26:29

问题


I have implemented a calendarview in my project, i can get the day of the month, the month and the year, but i cant find any method to get the day of the week, my code is this:

    view = new CalendarView(this);
    setContentView(view);


    view.setOnDateChangeListener(new OnDateChangeListener() {

        @Override
        public void onSelectedDayChange(CalendarView arg0, int year,
                int month, int dateb) { 

And when i choose a day in calendar i would need to get the week day to, I'm trying to get the answer but i cant find.

Sorry for my english.


回答1:


You could always use the Calendar and set it through the time you get from the calendar view:

Calendar selected = Calendar.getInstance();
selected.setTimeInMillis(view.getDate());
int dayOfWeek = selected.get(Calendar.DAY_OF_WEEK);

Each of the int values correspond to one of the days, for example Calendar.TUESDAY = 3

Hope it helps



来源:https://stackoverflow.com/questions/29299292/get-the-week-day-from-a-calendarview-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!