RecyclerView始终滚动到底部

时间:2018-02-22 13:52:21

标签: android android-recyclerview

我的RecycleView有7个项目(工作日),每个项目包含一个recycleView。

当我按下为具体位置指定的任何按钮时,RecycleView会滚动到底部。

的活动:

for col in df1.columns:
    if col in d.keys():
        df1[col] = df1[col].map(d[col])

SnappingLinearSmoothScrolling.class:

    obs gender  job
0   1   male    blue collar
1   2   male    white collar
2   3   female  white collar
3   4   male    blue collar

1 个答案:

答案 0 :(得分:0)

您忘记在break;声明中添加switch,如下所示添加

        switch (view.getId()) {
            case R.id.btn_mon:
                tasks_list.getLayoutManager().smoothScrollToPosition(tasks_list, null, 0);
            case R.id.btn_tue: 
                 break;
                tasks_list.getLayoutManager().smoothScrollToPosition(tasks_list, null, 1);
            case R.id.btn_wed:
                 break;
                tasks_list.getLayoutManager().smoothScrollToPosition(tasks_list, null, 2);
            case R.id.btn_thu:
                 break;
                tasks_list.getLayoutManager().smoothScrollToPosition(tasks_list, null, 3);
            case R.id.btn_fri:
                tasks_list.getLayoutManager().smoothScrollToPosition(tasks_list, null, 4);
            case R.id.btn_sat:
                 break;
                tasks_list.getLayoutManager().smoothScrollToPosition(tasks_list, null, 5);
            case R.id.btn_sun:
                 break;
                tasks_list.getLayoutManager().smoothScrollToPosition(tasks_list, null, 6);
                 break;
        }