Giter Site home page Giter Site logo

q648253885 / pulltorefresh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markmjw/pulltorefresh

0.0 1.0 0.0 958 KB

根据Maxwin的XListView改造而来,完善下拉刷新上拉加载更多的功能并实现自动刷新以及自动加载等功能, 并增加对ScrollView的支持。 原XListView参考链接:https://github.com/Maxwin-z/XListView-Android

License: Apache License 2.0

Java 100.00%

pulltorefresh's Introduction

PullToRefresh

注:本项目使用Android Studio开发

根据Maxwin的XListView改造而来:

1.完善下拉刷新上拉加载更多的功能
2.并增加对ScrollView的支持
3.增加自动刷新以及滚动到底部自动加载功能

原XListView参考链接:https://github.com/Maxwin-z/XListView-Android

XListView使用示例

设置XListView相关属性

mListView = (XListView) findViewById(R.id.list_view);
mListView.setPullRefreshEnable(true);
mListView.setPullLoadEnable(true);
mListView.setAutoLoadEnable(true);
mListView.setXListViewListener(this);
mListView.setRefreshTime(getTime());

mAdapter = new ArrayAdapter<String>(this, R.layout.vw_list_item, items);
mListView.setAdapter(mAdapter);

下拉刷新,下拉加载更多使用示例

@Override
public void onRefresh() {
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            mIndex = ++mRefreshIndex;
            items.clear();
            geneItems();
            mAdapter = new ArrayAdapter<String>(XListViewActivity.this, R.layout.vw_list_item,
                    items);
            mListView.setAdapter(mAdapter);
            onLoad();
        }
    }, 2500);
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        mListView.autoRefresh();
    }
}

@Override
public void onLoadMore() {
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            geneItems();
            mAdapter.notifyDataSetChanged();
            onLoad();
        }
    }, 2500);
}

XScrollView使用示例

设置XScrollView相关属性

mScrollView = (XScrollView) findViewById(R.id.scroll_view);
mScrollView.setPullRefreshEnable(true);
mScrollView.setPullLoadEnable(true);
mScrollView.setAutoLoadEnable(true);
mScrollView.setIXScrollViewListener(this);
mScrollView.setRefreshTime(getTime());

View content = LayoutInflater.from(this).inflate(R.layout.vw_scroll_view_content, null);

if (null != content) {
    mListView = (ListView) content.findViewById(R.id.content_list);
    mListView.setFocusable(false);
    mListView.setFocusableInTouchMode(false);

    mAdapter = new ArrayAdapter<String>(this, R.layout.vw_list_item, mItems);
    mListView.setAdapter(mAdapter);
    measureHeight();
}

mScrollView.setView(content);

下拉刷新,下拉加载更多使用示例

@Override
public void onRefresh() {
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            mIndex = ++mRefreshIndex;
            mItems.clear();
            geneItems();
            mAdapter = new ArrayAdapter<String>(XScrollViewActivity.this,
                    R.layout.vw_list_item, mItems);
            mListView.setAdapter(mAdapter);
            measureHeight();
            onLoad();
        }
    }, 2500);
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
   super.onWindowFocusChanged(hasFocus);

   if (hasFocus) {
       mScrollView.autoRefresh();
   }
}

@Override
public void onLoadMore() {
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            geneItems();
            mAdapter.notifyDataSetChanged();
            measureHeight();
            onLoad();
        }
    }, 2500);
}

##Screenshots Screenshot 0

Screenshot 1

Screenshot 2

Screenshot 3

License

Copyright (C) 2014 MarkMjw

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

pulltorefresh's People

Contributors

markmjw avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.