use of com.lcodecore.twinklingrefreshlayout.adapter.ScienceAdapter in project TwinklingRefreshLayout by lcodecorex.
the class ScienceActivity method setupGridView.
private void setupGridView(GridView gridView) {
final TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
SinaRefreshView headerView = new SinaRefreshView(this);
headerView.setArrowResource(R.drawable.arrow);
headerView.setTextColor(0xff745D5C);
// TextHeaderView headerView = (TextHeaderView) View.inflate(this,R.layout.header_tv,null);
refreshLayout.setHeaderView(headerView);
LoadingView loadingView = new LoadingView(this);
refreshLayout.setBottomView(loadingView);
adapter = new ScienceAdapter();
gridView.setAdapter(adapter);
adapter.refreshCard();
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
ToastUtil.show("item clicked!");
}
});
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
@Override
public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
adapter.refreshCard();
refreshLayout.finishRefreshing();
}
}, 2000);
}
@Override
public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
adapter.loadMoreCard();
refreshLayout.finishLoadmore();
}
}, 2000);
}
});
}
Aggregations