开发者

Using headerPullView in appcelerator

I'm using a tableView with a headerPullView. It works fine, but i want to show the headerPullView when i open the tab so the user can see that new data is loaded.

Can't find any infor开发者_Go百科mation on google or appcelerator docs.

I only found this: http://developer.appcelerator.com/blog/2010/05/how-to-create-a-tweetie-like-pull-to-refresh-table.html but this only shows how to update when the tab is already loaded. I'm looking for a way to show that loading headerPullView when i open that window.


You can't simulate a scroll with the headerPullView but you can fire an event of scroll.

Anyways what I would advise is to create a headerView and set the table height smaller and away from the top. Attache a listener to the open event.

var headerView = Ti.UI.createView({
    top: 0,
    height: 60
});

Ti.UI.currentWindow.addEventListener('open', function(e) {
    tableView.top = 60;
    tableView.height = 400;
    Ti.UI.currentWindow.add(headerView);
    Ti.UI.currentWindow.add(tableView);
});

Then just set it all back the way you need it when you scroll the table the first time.

var scrolled = 0;
tableView.addEventListener('scroll', function(e) {
    if(!scrolled) {
        tableView.top = 0;
        tableView.height = 460;
        Ti.UI.currentWindow.remove(headerView);
        scrolled = 1;
    }
    // scroll code
});

I'm not so sure why you need to do this however. After facebook replaced "shake to refresh" with this method I've started seeing it in almost all table apps and have come to just expect it. I assume many other users feel the same way about this?


you can use listView instead of tableView, it supports pull view already

check this http://docs.appcelerator.com/titanium/3.0/#!/guide/ListViews-section-37521650_ListViews-PulltoRefresh

or you can use this modules

https://github.com/jolicode/Alloy-PullToRefresh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜