安卓 日常问题 工作日志13

uri的 问题 uri在android指的是文件的路径 但是这个 是 一个对象 可以用 getpath()方法去获取数据

private List<Uri> uris;
uris.add(Uri.fromFile(new File(path + form.getLandformsImages().get(i).getName())));  //照片添加到uris  //可能 存取 照片的名字不对导致照片路径找不到
 //URI的结构组成 分为三部分  Uri.fromFile(new File(url))意思在于 访问手机本身的照片路径
//new File("xxx.xxx")  只是在内存中创建File文件映射对象,而并不会在硬盘中创建文件
//fromFile() 为检查文件是否是照片格式
//总体的意思是 根据路径以及照片名称访问 并将照片 添加到 uris中


GridLayoutManager rvLayout=new GridLayoutManager(getActivity(), 4);
 //Fragment并不是继承Context的,所以你要传入getActivity() 4 为列数 
met_imagetype_id.setLayoutManager(rvLayout);  //这里是为设置 recyclerview 布局方式 用setLayoutManager()去设置 有 横向 纵向 网格 此处为瀑布
将时间格式转换为字符串的格式
//调查日期 yyyy年MM月dd日HH时mm分ss秒
SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日");
String time = formatter.format(landForm.getInvestigation_date());
met_investigation_date.setText(time);
setText设置文本框里面要显示的东西
met_longitude.setText(landForm.getLongitude().toString());
       //复选框的展示 回显 调查类型
String iType =landForm.getInvestigation_type(); //获取数据库字符串

if(iType!=null){
cbdxdm.setChecked(iType.contains("地形地貌"));
cbdzlt.setChecked(iType.contains("地质露头"));
cbyrxx.setChecked( iType.contains("岩溶现象"));
cbqt.setChecked(iType.contains("其它"));
}else{
cbdxdm.setChecked(false);
cbdzlt.setChecked(false);
cbyrxx.setChecked(false);
cbqt.setChecked(false);}
复选框中 从数据库返回 json字符串 通过判断是否包含字符串 进行判断contains的字符串操作
https://blog.csdn.net/csxypr/article/details/92378336


原文地址:https://www.cnblogs.com/dushutai/p/12652093.html