RecyclerView中的SetOnScrollListener

时间:2017-01-09 06:02:57

标签: android listview android-recyclerview onscrolllistener

我使用listview来显示一些数据。我在listview中编写了setonScrollListener

mTransactions.setOnScrollListener(new AbsListView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

   }

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

if (mTransactionAdapter.getCount() > firstVisibleItem) {
    if (mTransactionAdapter.getItem(firstVisibleItem) != null) {
        String date = DateUtils.formatToDayMonthInWordAndYear(mTransactionAdapter.getItem(firstVisibleItem).getDate());
        if (!date.equals(mTransactionHeaderWrapper.getTextView().getText().toString())) {
            mTransactionHeader.setText(date);

        }


    }
}
}
});

现在我正在使用recyclerView,我不知道如何在RecyclerView中使用此代码。如果你知道如何重写我的代码,请帮助我。谢谢

0 个答案:

没有答案