在Android + PhoneGap中添加有关滚动的帖子

Add Posts on Scrolling in Android+PhoneGap

本文关键字:滚动 添加 Android PhoneGap      更新时间:2023-09-26

我正在开发使用JQuery Mobile和适用于Android的PhoneGap API的应用程序我的应用程序有一个新闻提要页面,一次显示 10 个新闻提要,然后在一个按钮下方显示下一个 10 个新闻提要,它工作正常并显示其他 10 个,直到显示所有新闻提要现在我希望它显示接下来的 10 个帖子,用户不要点击按钮,只需向下滚动并加载其他 10 个帖子(它是适用于 Android 操作系统的应用程序)

是否有任何插件或其他任何我可以使用的东西我的应用结构就像(在这个结构中 一个完整的帖子显示)

<div id="newsfeed_52" class="postwrapper">
    <div id="post_52" class="feeds-content">
        <div class="feeds-content-header"></div>
        <div class="harvestactivity"></div>
        <div class="hs-post-actions"></div>
    </div>
</div>

使用拉取刷新 iScroll。在这里演示


例:

    <div id="wrapper">
        <div id="scroller">
            //append anything when pull up: div, ul,...
            <ul id="items">
                //Append items when pull up.
            </ul>
            <div>scroll up to add more item</div>
        </div>
    </div>

或:

    <div id="wrapper">
        <ul id="items">
            //Append items when pull up.
        </ul>
    </div>

在javascript中:

myScroll = new iScroll('wrapper', {
    onScrollMove:function(){
        //do something when scroll move(identify position of scroll)
    },
    onScrollEnd:function(){
        //do something when scroll end(add more items)
    }
});

我用自定义方式做了

$(window).scroll(function (e)
{
if( ( $.mobile.activePage[0].id == 'PageIdInWhichYouWantToAppyThis' )
{
    if ( $(document).height() == $(window).scrollTop() + $(window).height() )
    {
        //here you can auto trigger that link which previously Waiting User Click
    }
}
});

根据演示,这是基本的,也许我需要很少的修改,但不是主要的谢谢