对官网Activity中一段话的疑惑
site:http://developer.android.com/guide/topics/fundamentals/activities.html
其中描述Activity中有一段文字
However, even if you do nothing and do not implementonSaveInstanceState()
, some of the activity state is restored by theActivity
class's default implementation of onSaveInstanceState()
. Specifically, the default implementation calls onSaveInstanceState()
for every View
in the layout, which allows each view to provide information about itself that should be saved. Almost every widget in the Android framework implements this method as appropriate, such that any visible changes to the UI are automatically saved and restored when your activity is recreated. For example, the EditText
widget saves any text entered by the user and the CheckBox
widget saves whether it's checked or not. The only work required by you is to provide a unique ID (with the android:id
attribute) for each widget you want to save its state. If a widget does not have an ID, then it cannot save its state.
最后一句
为什么我不给View添加一个ID,还是会默认的替我们保存数据呢。我测试的是用TextView。有人能帮解答下吗?
上一篇: 麻酱花卷的做法你知道吗
下一篇: 食用榴莲禁忌有哪些
推荐阅读