如何解决每次重新创建滚动位置后,如何将滚动位置保存在回收站视图中?
下面是每次点击按钮时调用的方法,它创建一个包含新数据的列表
; ffi-lib: couldn't open "/usr/lib/libwiringPiDev.so"
; (/usr/lib/libwiringPiDev.so: undefined symbol: digitalRead) [,bt for
; context]
如何保存滚动位置,以便下次单击按钮时,列表保持在同一位置
解决方法
好吧,每次重新创建时都使用它。
linearLayoutManager.scrollToPositionWithOffset(pos,0);
代码:
public void fire(View v) {
String temp = editText.getText().toString();
myRecyclerView = new MyRecyclerView(this,500,temp);
recyclerView.setAdapter(myRecyclerView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(linearLayoutManager);
myRecyclerView.setClickListener(this);
//assuming th layout is loaded. set pos as the position you want to scroll to
int pos=0;
linearLayoutManager.scrollToPositionWithOffset(pos,0);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。