Created
March 26, 2015 08:11
-
-
Save parachvte/45e4b5fe801880290002 to your computer and use it in GitHub Desktop.
Android - SwipeRefreshLayout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:background="#812373"> | |
<android.support.v4.widget.SwipeRefreshLayout | |
android:id="@+id/swipe_refresh_layout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<ScrollView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<TextView | |
android:text="Hello, World!" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="16dp" | |
android:gravity="center"/> | |
</ScrollView> | |
</android.support.v4.widget.SwipeRefreshLayout> | |
</LinearLayout> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ryannnnnnn.test_swipe_refresh_layout; | |
import android.app.Activity; | |
import android.graphics.Color; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.support.v4.widget.SwipeRefreshLayout; | |
public class MyActivity extends Activity implements SwipeRefreshLayout.OnRefreshListener { | |
SwipeRefreshLayout mSwipeRefreshLayout; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); | |
mSwipeRefreshLayout.setOnRefreshListener(this); | |
mSwipeRefreshLayout.setColorSchemeColors(Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE); | |
} | |
@Override | |
public void onRefresh() { | |
new Handler().postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
mSwipeRefreshLayout.setRefreshing(false); | |
} | |
}, 5000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment