【发布时间】:2019-05-09 08:33:40
【问题描述】:
我正在使用下面的代码来自动滚动我的回收站视图。
private final Runnable SCROLLING_RUNNABLE = new Runnable() {
@Override
public void run() {
mRecyclerView_news.smoothScrollBy(pixelsToMove, 0);
mHandler.postDelayed(this, duration);
}
};
private void scrollRV(){
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
mRecyclerView_news.setLayoutManager(layoutManager);
mRecyclerView_news.setHasFixedSize(true);
mAdapter = new NewsAdapter(MainActivity.this, newsList, this);
mRecyclerView_news.setAdapter(mAdapter);
mHandler.postDelayed(SCROLLING_RUNNABLE, 500);
}
我也在实现一个 Click 监听器,但是当 Recyclerview 滚动时,没有一个项目被点击。当 recyclerview 不滚动时,点击监听器工作正常。
我该如何克服这个问题?
【问题讨论】:
-
你在哪里调用
scrollRV方法?
标签: java android android-recyclerview scroll android-adapter