Android Fullcalendar左右滑动功能,也适用于dayClick

Android Fullcalendar左右滑动功能,也适用于dayClick,android,fullcalendar,Android,Fullcalendar,如何实现touch device fullcalendar swipe功能,允许我来回更改月份,但也适用于dayClick或日记中的任何其他单击事件?我尝试了许多不同的解决方案,Android类、fullcalendar修复程序、js库(hammer很接近)没有什么能完美地为我实现这一技巧,除了吼叫 假设您在WebView中设置并运行完整日历时没有问题: 在活动中,您需要为您的webView设置一个触摸监听器: myWebView.setOnTouchListener(

如何实现touch device fullcalendar swipe功能,允许我来回更改月份,但也适用于dayClick或日记中的任何其他单击事件?

我尝试了许多不同的解决方案,Android类、fullcalendar修复程序、js库(hammer很接近)没有什么能完美地为我实现这一技巧,除了吼叫

假设您在WebView中设置并运行完整日历时没有问题:

在活动中,您需要为您的webView设置一个触摸监听器:

myWebView.setOnTouchListener(
                new View.OnTouchListener() {
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        // TODO Auto-generated method stub
                        switch (event.getAction()) {
                            case MotionEvent.ACTION_DOWN:
                                x1 = event.getX();
                                break;
                            case MotionEvent.ACTION_UP:
                                x2 = event.getX();
                                float deltaX = x2 - x1;
                                //check if the user's funger has moved significantly. Tiny bit of movement is very usual and common during touch, so >0 and <0 won't work.
                                if (deltaX < -210) {
                                    Toast.makeText(MainActivity.this, String.valueOf(deltaX), Toast.LENGTH_SHORT).show();
                                    //Swipes RtoL move to the next month
                                    myWebView.loadUrl("javascript: $('#calendar').fullCalendar('next');");
                                } else if (deltaX > 210) {
                                    //Swipes LtoR move to the previous month
                                    Toast.makeText(MainActivity.this, String.valueOf(deltaX), Toast.LENGTH_SHORT).show();
                                    myWebView.loadUrl("javascript: $('#calendar').fullCalendar('prev');");
                                } else if (deltaX > -210 && deltaX < 210) { //Adjust those numbers for your needs
                                    //itsa touch
                                    myWebView.loadUrl("javascript: goToDateClicked();");


                                }
                                break;
                        }

                        return false;
                    }
                });
myWebView.setOnTouchListener(
新视图。OnTouchListener(){
@凌驾
公共布尔onTouch(视图v,运动事件){
//TODO自动生成的方法存根
开关(event.getAction()){
case MotionEvent.ACTION\u DOWN:
x1=event.getX();
打破
case MotionEvent.ACTION\u UP:
x2=event.getX();
浮动deltaX=x2-x1;

//检查用户的funger是否有明显的移动。在触摸过程中,微小的移动是非常常见的,因此>0和@YvetteColomb:我绝对不反对。我的担心不同。@Rohit5k2请告诉我,因为还不清楚……如果我的评论没有被删除的话。@Rohit5k2您在这个网站上的原因是错误的。请编写一些cli代码让你自己获得所有你想要的声誉。有些人在这里分享知识,半小时不哭。@Rohit5k2顺便说一句,答案是开放的,你仍然可以发布你的,如果更好的话,它会获得更多的选票。
<script type="text/javascript">
//Declare a global date variable to set the callendar date to, when a day is clicked
var globalDate;

function goToDateClicked()
{
    //Change the view to a desired view and clicked date
    $('#calendar').fullCalendar('changeView', 'agendaDay');
    $('#calendar').fullCalendar('gotoDate', globalDate );
}
jQuery(document).ready(function () {
    $('#calendar').fullCalendar({

    //OPTIONS
         dayClick: function(date, jsEvent, view) {
         //On day click only set the date clicked. If it's a swipe then you don't have to worry about going back and forth into views and some weird logic to prevent swipe to date changes.
         //If it's a click then the Android code behind takes care of the date/view change, all it needs is the bellow date.
            globalDate = date.format();
        }
    });

    //DIARY RELATED BUTTONS CLICKS
    $(".fc-today-button").click(function() {
        $('#calendar').fullCalendar('changeView', 'month');
    });

});
</script>
<div id='calendar'></div>