安卓 日常问题 工作日志15

关于复选框的问题 

等下 目前 要求 每天得 整理一下 目前 android 招聘的 技能要求 或插件 或要求 进行 总结 和学习 正确 今天或明天 将 该项目的 都总结完毕 相当于 3 个月的项目总结 

1. 负责 android 客户端教育相关产品的研发
2. 负责 android 客户端的适配及性能优化
3. 设计良好的代码结构,不断迭代重构
4. 带领初级工程师共同完成研发任务
 
职位要求:
有过相对完整成功的教育类产品(视频、互动、游戏、社交、电商等)相关经历
1. 计算机相关专业,5年以上Android客户端开发经验;
2. 有扎实的Java/Android开发基础和多线程开发基础
3. 对Android的UI架构,动效和性能优化有一定的研究,能够实现较复杂的用户界面交互、动画以及视觉效果
4. 熟悉Android应用内存,性能,架构优化,掌握相关的技巧和方法,并且解决过这类问题
7. 良好的沟通和团队协作能力、热爱技术、责任心强、能推动技术框架的落地使用;
 
 1.多线程的问题 主要是 高并发 优化内存 等  性能优化  android的 开发框架 
这些都需要解决 
 

android 复选框 我们项目 是 将数据 存储成 json字符串 存入数据库 

现在 可以通过 geson 去 解析字符串 

目前 安卓生成字符串 还是没有快捷已经成熟的插件 好吧 是我没找到 主要有 两种方法 1 对像添加 2 直接 输入 

今天来讲讲 复选框 和 json字符串的使用 

首先 常用的 数据类型转换 很重要  将字符串转换成 double类型 

landForm.setLongitude(Double.parseDouble(met_longitude.getText().toString().trim()));//经度
标准的遍历checkbox找到被选中的并加入到json字符串中
      //遍历所有的checkbox 找到被选中的 然后变成json格式传入数据库保存  将选中的存入对象
JSONObject InvestigationTypeJson = new JSONObject(); //新建json对象
//遍历所有布局中的CheckedBox控件
int count = layoutType.getChildCount(); // 获得子控件的数量 子控件 就是checkbox(复选框) private LinearLayout layoutType ;之前新建的 过会 我把xml代码写后面
                for(int i = 0;i < count;i++){
// 获得子控件对象
View child = layoutType.getChildAt(i); //getChildAt() 在集合中返回指定位置的视图。 通过索引i 返回View

// 判断是否是CheckBox
if(child instanceof CheckBox){ //判斷這个视图 view 是不是 checkBox类型的视图
//转为CheckBox对象
CheckBox cb = (CheckBox)child; /强转 也是 固定格式 当可以instanceof后 一般都强转
if(cb.isChecked()){
// //遍历被选中的项
String ck= cb.getText().toString(); //复选框的名字
boolean bl=true; //复选框的状态
//将选中的选项加入到json对象中
try {
InvestigationTypeJson.put(ck,bl); //將复选框的名字 以及状态 写入到 json对象里
} catch (JSONException e) {
e.printStackTrace();
}
} //将遍历完的json对象转换为字符串

}

}
String InvestigationTypeString = InvestigationTypeJson.toString();//将json对象转换成字符串
// 拼接好后存入对象 然后统一存到数据库
landForm.setInvestigation_type(InvestigationTypeString);//调查类型

xml文件 

<LinearLayout
android:id="@+id/layoutType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="调查类型:"
android:textColor="#333333"
android:textSize="14sp" />
<!-- 新增复选框 包含选项 地形地貌,地质露头,岩溶现象,其它 想法到check发生变化判
定将选定的全部写在文本上然后传入后台 拼接字符串传入后台写在数据库中 或者这个是单选框就不会这莫麻烦了 -->
<CheckBox
android:id="@+id/cbdxdm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvHead"
android:layout_marginTop="0dp"
android:layout_toLeftOf="@+id/tvHead"
android:text="地形地貌" />

<CheckBox
android:id="@+id/cbdzlt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvHead"
android:layout_marginTop="0dp"
android:layout_toLeftOf="@+id/tvHead"
android:text="地质露头" />

<CheckBox
android:id="@+id/cbyrxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvHead"
android:layout_marginTop="0dp"
android:layout_toLeftOf="@+id/tvHead"
android:text="岩溶现象" />

<CheckBox
android:id="@+id/cbqt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvHead"
android:layout_marginTop="0dp"
android:layout_toLeftOf="@+id/tvHead"
android:text="其它" />

<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/met_investigation_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
app:met_baseColor="@android:color/black"
app:met_primaryColor="?colorAccent"
app:met_singleLineEllipsis="true" />

</LinearLayout>

猜你喜欢

转载自www.cnblogs.com/dushutai/p/12653143.html
今日推荐