Android:关于Configurations
来源:互联网 发布:excel函数不重复数据 编辑:程序博客网 时间:2024/05/28 23:22
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:
<activity android:name=”.TodoList”
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
- Android:关于Configurations
- configurations
- 关于j2me中Configurations and Profiles 及MIDP
- .NET 部署-04关于生成配置(Build Configurations)
- Support different Android device configurations with dimension resources
- 安卓 运行、调试 配置 android Run/debug configurations
- Proftpd Configurations
- EGL Configurations
- EGL Configurations
- Ivy Configurations
- Run Configurations
- Hierarchical Configurations
- Ubuntu Configurations
- 关于studio中的Run/Debug Configurations不能运行的问题及解决方案
- Android studio升级3.0,提示“Error:Cannot choose between the following configurations of project”错误
- Emulator Security Configurations
- Sample cisco NTP Configurations
- Com+ security configurations
- Apad Qzone项目总结(一)---发布!!!
- Prefuse及相关数据结构可视化工具
- 云计算之分布式文件系统
- 归并排序
- 使用maven常见的误区与解决办法!
- Android:关于Configurations
- 数据库名、实例名和ORACLE_SID的区别
- 字符串中替换宏
- EL表达式
- FLash 学习
- socket udp
- jvm学习笔记(1)class文件
- 日有所思,夜有所梦
- jvm学习笔记(2)多线程的相关原理