“锤子下拉”,东半球最优雅的下拉控件。(也叫SmartisanRefreshableLayout。)
本项目模仿“锤子阅读”的下拉效果。仅供学习交流,请勿用于商业用途。
下面是我做的过程中,每个阶段有意思的地方: (下面把“可刷新”的最小距离叫刷新距离)
只需在里面加入ListView,仍然保持了ListView的正常使用,不会对它造成什么影响。
<com.hougr.smartisanpull.SmartisanRefreshableLayout
android:id="@+id/refreshable_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:scrollbars="none" >
</ListView>
</com.hougr.smartisanpull.SmartisanRefreshableLayout>
mSmartisanRefreshableLayout = (SmartisanRefreshableLayout) findViewById(R.id.refreshable_view);
mSmartisanRefreshableLayout.setOnRefreshListener(new SmartisanRefreshableLayout.PullToRefreshListener() {
@Override
public void onRefresh() {
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void onRefreshFinished() {
mSmartisanRefreshableLayout.finishRefreshing();
mViewHolderAdapter.addToListHead((mRefreshCount++)+" 喜欢的话,可以在github上赏我一颗star");
}
});
喜欢的话,可以点击右上角的star。感谢。