Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An extension of android.support.v4.widget.SwipeRefreshLayout with loading more function

License

Notifications You must be signed in to change notification settings

fjpengyu/SwipeRefreshLayout

Repository files navigation

SwipeRefreshLayout

An extension of android.support.v4.widget.SwipeRefreshLayout with loading more function

Note

  • Support ListView
  • Support RecyclerView (Todo)
  • Custom your FooterView and load more action
  • Start and stop refresh or load more manually

Demo

Download apk

Screenshot

Gif

How to Use

In your build.gradle:

dependencies {
 compile 'com.demievil.library:refreshlayout:1.0.0@aar'
}

Click to check the latest version

Simple Example

  • Use RefreshLayout in your layout
<com.demievil.library.RefreshLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/swipe_container"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".MainActivity">
 <ListView
 android:id="@+id/list"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="#FFFFFF"
 android:dividerHeight="1px"
 android:footerDividersEnabled="false"
 tools:listitem="@layout/list_item" />
</com.demievil.library.RefreshLayout>
  • Customize your footer layout to indicate a loading progress such as:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/footer_layout"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="#FFFFFF"
 android:gravity="center"
 android:padding="8dp">
 <TextView
 android:id="@+id/text_more"
 android:layout_width="match_parent"
 android:layout_height="40dp"
 android:layout_gravity="center|top"
 android:gravity="center"
 android:text="more..."
 android:textSize="16sp" />
 <ProgressBar
 android:id="@+id/load_progress_bar"
 style="@android:style/Widget.DeviceDefault.Light.ProgressBar"
 android:layout_width="wrap_content"
 android:layout_height="40dp"
 android:layout_gravity="center|top"
 android:indeterminate="true"
 android:visibility="gone" />
</FrameLayout>
  • Get instance and use it:
 RefreshLayout mRefreshLayout;
 ListView mListView;
 View footerLayout;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 mRefreshLayout = (RefreshLayout) findViewById(R.id.swipe_container);
 mListView = (ListView) findViewById(R.id.list);
 footerLayout = getLayoutInflater().inflate(R.layout.listview_footer, null);
 mListView.addFooterView(footerLayout);
 mRefreshLayout.setChildView(mListView);
	
 mListView.setAdapter(mAdapter);
 mRefreshLayout.setColorSchemeResources(R.color.google_blue,
 R.color.google_green,
 R.color.google_red,
 R.color.google_yellow);
 mRefreshLayout.setOnRefreshListener(new RefreshLayout.OnRefreshListener() {
 @Override
 public void onRefresh() {
	 // start to refresh
 }
 });
 mRefreshLayout.setOnLoadListener(new RefreshLayout.OnLoadListener() {
 @Override
 public void onLoad() {
 // start to load 
 }
 });
 }
  • You can start and stop refresh or load more as follows:
//start and stop refresh manually
mRefreshLayout.setRefreshing(true);
mRefreshLayout.setRefreshing(false);
//start and stop load more manually
mRefreshLayout.setLoading(true); //this will jump to bottom anf callback OnLoadListener.onLoad()
mRefreshLayout.setLoading(false); //this will reset laod more coordinates

Thanks

SwipeRefreshLayout

License

Copyright (c) 2015 Demievil

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.

About

An extension of android.support.v4.widget.SwipeRefreshLayout with loading more function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%

AltStyle によって変換されたページ (->オリジナル) /