The following list describes the confi guration changes you can specify:
 ❑ orientation  The screen has been rotated between portrait and landscape.
 ❑ keyboardHidden  The keyboard has been exposed or hidden.
 ❑ fontScale  The user has changed the preferred font size.
 ❑ locale  The user has chosen a different language setting.
 ❑ keyboard  The type of keyboard has changed; for example, the phone may have a 12 keypad 
that fl ips out to reveal a full keyboard.
 ❑ touchscreen or navigation  The type of keyboard or navigation method has changed. Neither of these events should normally happen.
You can select multiple events to handle by separating the values with a pipe (|).
The following XML snippet shows an activity node declaring that it will handle changes in screen orientation and keyboard visibility:
          android:label=”@string/app_name” 
          android:theme=”@style/TodoTheme”
          android:configChanges=”orientation|keyboard”/>
Adding this attribute suppresses the restart for the specifi ed confi guration changes, instead, triggering 
the onConfigurationChanged method in the Activity. Override this method to handle the confi guration changes using the passed-in Configuration object to determine the new confi guration values, as 
shown in the following skeleton code. Be sure to call back to the super class and reload any resource 
values that the Activity uses in case they’ve changed.
@Override 
public void onConfigurationChanged(Configuration _newConfig) {
  super.onConfigurationChanged(_newConfig);  
  [ ... Update any UI based on resource values ... ]
  if (_newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
    [ ... React to different orientation ... ]
  }
  if (_newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) {
    [ ... React to changed keyboard visibility ... ]
  }
}
When onConfigurationChanged is called, the Activity’s Resource variables will have already been 
updated with the new values so they’ll be safe to use. 
Any confi guration change that you don’t explicitly fl ag as being handled by your application will still 
cause an application restart without a call to onConfigurationChanged

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android学习小结2
  2. 利用HTML5开发Android
  3. android AsyncTask类的使用
  4. 学习 Android(安卓)Handler 消息机制需要
  5. Android官方DrawerLayout 抽屉式侧滑菜单
  6. Android中onInterceptTouchEvent与onTouc
  7. Android(安卓)ListView 设置分割线的设置
  8. Android调试笔记——FATAL EXCEPTION: ma
  9. Android学习笔记(二三): 多页显示-Flipper的
  10. android 开发 新建工程