安卓:CalendarView OnDateChangeLIstener [英] Android: CalendarView OnDateChangeLIstener

查看:755
本文介绍了安卓:CalendarView OnDateChangeLIstener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了这个监听器为了让我来显示一些特定的日期被点击时,但问题是,当我滚动CalendarView下来,它会自动显示出来的东西,但我没有点击任何东西,我只是向下滚动到花药月CalendarView再有走一段,说吐司或日志,无论(我想这是有道理的,因为监听器本身触发`onDateChange既然向下滚动日历也会改变当前选择的日期)。所以我的问题是没有办法,我可能会使用只是一个替代品ondateChange监听器,序,以避免这种情况,当我向下滚动calendarView去再过一个月,它会自动发射的lisntener所有监听CalendarView。

I've already implemented this listener in order for me to display something when a certain date is clicked, but the problem is that when i scroll the CalendarView down, it automatically displayed something but i didn't click anything, i just scrolled down to anther month in CalendarView and then there goes a, say a Toast or a Log, whichever (I guess it makes sense since the listener itself fires `onDateChange and since scrolling down the calendar also changes the date currently selected). So my question is that is there any listener for CalendarView that i might use just a alternative to ondateChange listener, inorder to avoid the situation that when i scroll down the calendarView to go to another month it automatically fired the lisntener.

任何谁知道替代听者以CalendarView或有人知道解决方法吗?请不要共享

Anyone who knows an alternative listner to CalendarView or anyone knows a workaround? please do share

推荐答案

当您滚动日历 onSelectedDayChange 方法的行为就像你点击不同的日期,但的不会改变当前的日期设置。所以HFDO5是正确的,你只需要在创建日历保存当前日期: 长日期= calendar.getDate();

When you are scrolling the calendar onSelectedDayChange method behaves like you click on different date but that won't change current date settings. So HFDO5 was right, you just need to save current date when you create your calendar: Long date = calendar.getDate();

和其签入 onSelectedDayChange

if(callendar.getDate() != date){
date = calendar.getDate(); //new current date
//date is changed on real click...do things..

}

这篇关于安卓:CalendarView OnDateChangeLIstener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆