活动 1:SelectBatchStep。RecyclerView 填充了 MySQL 数据库数据
活动 2:完成。在数据库中插入新数据的简单活动。
Activity 1 会在 Activity 2 完成后重新加载,以显示更新后的 recyclerView 项目。
我正在尝试将滚动位置保存在 recyclerview 活动 1 中。我开始了一个新的活动 2,但是当我回调 recyclerview 活动 1 时滚动位置没有恢复。
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putInt(SCROLL,scrollpositionkeeper);
super.onSaveInstanceState(savedInstanceState);
Log.v(TAG,"scrollpositionsaved"+savedInstanceState);
}
当我开始新的活动 2 时,Logcat 显示捆绑包已保存并且滚动位置已正确保存。
Activity 2 使用 com.daimajia.swipe.SwipeLayout 库从回收器适配器启动。
活动 1 从活动 2 中调用如下:
Intent intent1 = new Intent(DoneBy.this, SelectBatchStep.class);
活动 1 有以下内容:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
scrollrecovered = savedInstanceState.getInt(SCROLL);
}
else {
scrollrecovered=0;
}
Log.v(TAG,"scrollpositionrecovered"+savedInstanceState);
setContentView(R.layout.activity_select_batch_step);
Activity 1 来到前面,logcat 显示 Bundle 为空
为什么保存的捆绑包为空?