首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

对官网Activity中一段话的不解

2012-09-29 
对官网Activity中一段话的疑惑site:http://developer.android.com/guide/topics/fundamentals/activities.

对官网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.


最后一句

?

?写道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。有人能帮解答下吗?

热点排行