details
2015-07-30 11:17
330 查看
getveiw(). 在fragment 中可以直接获取当前fragment的主view
多线程中将线程不安全的变量转化为线程安全的变量
context.getString(int resId, Object... formatArgs):
可以获取string.xml中定义的字符串,如:
<string name="mystr">我的字符串</string>,为了获取这个mystr,可以用如下方法:
this.getString(R.string.mystr);
在线程中的睡眠:
try{
if(!myFile.exists())
myFile.createNewFile();
else //如果不存在则扔出异常
throw new Exception("The new file already exists!");
}catch(Exception e){
System.out.println("无法创建新文件!");
ex.printStackTrace();
}
多线程中将线程不安全的变量转化为线程安全的变量
:Collections.synchronizedList(new ArrayList());
context.getString(int resId, Object... formatArgs):
可以获取string.xml中定义的字符串,如:
<string name="mystr">我的字符串</string>,为了获取这个mystr,可以用如下方法:
this.getString(R.string.mystr);
在线程中的睡眠:
SystemClock.sleep(100L);
Thread.sleep(),前者不会忽略InterruptedException中断异常,,后者会。
try{
if(!myFile.exists())
myFile.createNewFile();
else //如果不存在则扔出异常
throw new Exception("The new file already exists!");
}catch(Exception e){
System.out.println("无法创建新文件!");
ex.printStackTrace();
}
相关文章推荐
- Handler sendMessage 与 obtainMessage (sendToTarget)比较
- 有关人工智能的假设
- HDU 1022 Train Problem I
- UVALive 6800 The Mountain of Gold (bellman_ford判负环)
- uva 11374 Airport Express(最短路)
- DataBinder.Eval和Container.DataItem(DataRowView)有什么区别
- Open-air shopping malls(二分半径,两元交面积)
- 基于CLM(Constrained local model)人脸点检测算法
- Easy 2048 Again - ZOJ 3802 像缩进dp
- 怎么提高RailS应用的性能
- Rails项目中避免滥用这三种特性
- hdu 5319 Painter(杭电多校赛第三场)
- use sleep() to gain thread predictability
- HUAS Summer Trainning #3~B
- mongodb3.0.4 MongoDB-CR Authentication failed
- Everything Will Ultimately Fail
- 2015 Multi-University Training Contest 1
- hdoj 3420 bus Fair
- 1.2-对象的建立-main
- hdu 5316 Magician 2015 Multi-University Training Contest 3