1
我在我的Activity
中有一堆int
,但当屏幕旋转时它会变空。 我搜索了一下,找出onSaveInstanceState
,但似乎我不能以这种方式存储堆栈?它只是用于主变量类型,对吗? 我该怎么办?有任何想法吗?如何在onSaveInstanceState()中存储堆栈?
我在我的Activity
中有一堆int
,但当屏幕旋转时它会变空。 我搜索了一下,找出onSaveInstanceState
,但似乎我不能以这种方式存储堆栈?它只是用于主变量类型,对吗? 我该怎么办?有任何想法吗?如何在onSaveInstanceState()中存储堆栈?
堆栈是一个实现Serializable接口的类。
所以,你可以使用
outState.putSerializable("stack", stack);
存储的onSaveInstanceState中(捆绑outState)堆栈和
Stack<Integer> stack=(Stack<Integer>) savedInstanceState.getSerializable("stack");
堆的什么检索栈? – Blackbelt
@Blackbelt:int – ZahraZT