Android中bool的使用
来源:互联网 发布:android权威指南 源码 编辑:程序博客网 时间:2024/05/24 07:14
今天由于不同手机版本需要执行不一样的代码,但是overlay里面呢又不支持传入代码,后来想到使用bool属性来进行控制
首先在Values里面新建Config.xml,之后代码如下:
<resources> <!-- Maximum recording length in milliseconds. 0 means unlimited. --> <integer name="max_video_recording_length">0</integer> <bool name="config_show_chezai">true</bool></resources>
在java中应用:
boolean showCheZai = getResources().getBoolean(R.bool.config_show_chezai);if (showCheZai) {try {Intent intentID = getIntent();Bundle bundle = intentID.getExtras();LOW_BATTERY_LEVEL = bundle.getInt("id");Log.d(TAG, "text = " + LOW_BATTERY_LEVEL);} catch (Exception e) {LOW_BATTERY_LEVEL = 5;Log.i("exception", e.toString());}if (current <= LOW_BATTERY_LEVEL) {// showLowBatteryDialog();Intent intent1 = new Intent(CameraActivity.this, showDialogActivity.class);startActivity(intent1);CameraActivity.this.finish();CameraHolder.instance().keep();closeModule(mCurrentModule);} else if (mLowBatteryDialog != null && mLowBatteryDialog.isShowing()) {// Dismiss the dialog when the battery level is not// low by// charging.// This case will happen when charging with the// dialog// showing.mLowBatteryDialog.dismiss();CameraHolder.instance().keep();setModuleFromIndex(mCurrentModuleIndex);openModule(mCurrentModule);}}else{ ....}
默认为真,执行上面一块代码,否则执行下面一块
1 0
- Android中bool的使用
- c语言中bool型的使用
- vc中bool与BOOL的区别
- C++中BOOL 与bool的区别
- vc中bool与BOOL的区别
- vc中bool与BOOL的区别
- c++中BOOL和bool的区别
- c++中BOOL和bool的区别
- c++中BOOL和bool的区别
- c++中BOOL和bool的区别
- c++中BOOL和bool的区别
- c++中BOOL和bool的区别
- c++中BOOL和bool的区别
- C++中 bool,BOOL ,VARIANT_BOOL 的区别
- C++中BOOL和bool的区别
- vc中bool与BOOL的区别
- C++中BOOL和bool的区别
- c++中BOOL和bool的区别
- SpringMVC学习系列-后记 解决GET请求时中文乱码的问题
- 教你学会使用Git和远程代码库
- 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}。由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2。如果不存在
- oc----巧用storyboard/xib的小技巧,Preview~预览,提高效率
- Windows 7下安装使用Sublime Text 3
- Android中bool的使用
- Shell正则表达式与通配符
- Android 属性动画(Property Animation) 完全解析 (上)
- Nhiberate 学习 (二) 搭建环境出现的问题
- Android简单对话框、输入对话框、单选对话框、复选对话框、列表对话框、自定义对话框、时间对话框
- wuzhicms 发送邮件
- iOS多线程之NSThread
- 使用响应式编程(RxJava)开发Android App
- 暴力版java 吸血鬼数字 代码 --- 依靠循环嵌套解决。