Created
August 6, 2014 04:36
-
-
Save nein37/56d99b3d26dbc1ed5821 to your computer and use it in GitHub Desktop.
SwipeRefreshLayout覚え書き ref: http://qiita.com/nein37/items/c9ae7c8e3489b1276c14
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
public class RefreshFragment extends Fragment implements | |
SwipeRefreshLayout.OnRefreshListener { | |
private SwipeRefreshLayout mSwipeRefreshLayout; | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
View view = inflater.inflate(R.layout.refreshlayout, null); | |
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipelayout); | |
// 色設定 | |
mSwipeRefreshLayout.setColorSchemeResources(R.color.red, | |
R.color.green, R.color.blue, | |
R.color.orange); | |
// Listenerをセット | |
mSwipeRefreshLayout.setOnRefreshListener(this); | |
return view; | |
} | |
@Override | |
public void onRefresh() { | |
// 更新処理を実装する | |
// ここでは単純に2秒後にインジケータ非表示 | |
new Handler().postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
// 更新が終了したらインジケータ非表示 | |
mSwipeRefreshLayout.setRefreshing(false); | |
} | |
}, 2000); | |
} | |
} |
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
<android.support.v4.widget.SwipeRefreshLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/swipelayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<ListView | |
android:id="@id/android:list" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> | |
</android.support.v4.widget.SwipeRefreshLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment