我有一个水平RecyclerView
来显示当前周即将到来的生日的人。我已将自动滚动添加到RecyclerView
,活动开始后RecyclerView
开始滚动...
自动滚动RecyclerView
...的代码
final int duration = 50;
final int pixelsToMove = 10;
final Handler mHandler = new Handler(Looper.getMainLooper());
final Runnable SCROLLING_RUNNABLE = new Runnable() {
@Override
public void run() {
birthdayRV.smoothScrollBy(pixelsToMove, 0);
mHandler.postDelayed(this, duration);
}
};
birthdayAdapter = new BirthdayAdapter(birthdayModelList, HomeActivity.this);
final LinearLayoutManager layoutManager = new LinearLayoutManager(HomeActivity.this, LinearLayoutManager.HORIZONTAL, false);
birthdayRV.setHasFixedSize(true);
birthdayRV.setLayoutManager(layoutManager);
birthdayRV.setAdapter(birthdayAdapter);
birthdayRV.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(final RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int lastItem = layoutManager.findLastCompletelyVisibleItemPosition();
if (lastItem == layoutManager.getItemCount() - 1) {
mHandler.removeCallbacks(SCROLLING_RUNNABLE);
Handler postHandler = new Handler();
postHandler.postDelayed(new Runnable() {
@Override
public void run() {
birthdayRV.setAdapter(null);
birthdayRV.setAdapter(birthdayAdapter);
birthdayRV.setClickable(true);
mHandler.postDelayed(SCROLLING_RUNNABLE, 2000);
}
}, 2000);
}
}
});
mHandler.postDelayed(SCROLLING_RUNNABLE, 2000);
我在onCLickListner
内的cardViews
中设置了recylerView(adapter)
,以查看有关人员的详细信息,点击相应的cardViews
...
我的问题是recyclerView
开始滚动时,clickListener
不起作用...如果您需要进一步的说明,请询问...帮助我...