您的位置:首页 > 大数据 > 人工智能

details

2015-07-30 11:17 330 查看
getveiw(). 在fragment 中可以直接获取当前fragment的主view

多线程中将线程不安全的变量转化为线程安全的变量

: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();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: