昨日总结:

  1.具体情况已经写在了昨天的当日总结当中

  遇到的问题:

  1.toolbar的返回键与菜单键冲突,导致无法同时使用

  今天的任务:

  1.完整实现课程查询任务

  当日总结:

  1.完整实现,唯一的遗憾就是课程信息不完全,导致只能查询个别信息

  2.首先实现的是listview中的子组件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<!-- 类似于iOS开发中Cell的布局 -->
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/lesson_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:textSize="20dp"
android:text="课程名称"
android:textColor="#ff0000"
android:lines="1"/>
<TextView
android:id="@+id/teacher_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:textSize="15dp"
android:text="教师名称"
android:lines="1"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="25dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15dp"
android:id="@+id/lesson_building"
android:text="教学楼"
android:lines="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="1"
android:id="@+id/lesson_classroom"
android:textSize="15dp"
android:text="教室" /> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="1"
android:textSize="15dp"
android:id="@+id/lesson_nature"
android:text="课程性质"/>
</LinearLayout> <LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginBottom="10dp">
<TextView
android:id="@+id/lesson_week"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15dp"
android:text="星期"
android:lines="1"/>
<TextView
android:id="@+id/lesson_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="1"
android:textSize="15dp"
android:text="节次" /> <TextView
android:id="@+id/lesson_sumweek"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="1"
android:textSize="15dp"
android:text="周次"/>
</LinearLayout> </LinearLayout>

  3,然后我们需要适配器

    public LessonAdapter(Context context, int resource, List<LessonBean> objects) {
super(context, resource, objects);
resourceId = resource;
} @Override
/**
* @param position 当前设置的Cell行数,类似于iOS开发中的indexPath.row
*/
public View getView(int position, View convertView, ViewGroup parent) {
LessonBean lesson = getItem(position); View lessonView = LayoutInflater.from(getContext()).inflate(resourceId, null); TextView lesson_name = lessonView.findViewById(R.id.lesson_name);
TextView teacher_name = lessonView.findViewById(R.id.teacher_name);
TextView lesson_building = lessonView.findViewById(R.id.lesson_building);
TextView lesson_classroom = lessonView.findViewById(R.id.lesson_classroom);
TextView lesson_nature = lessonView.findViewById(R.id.lesson_nature);
TextView lesson_week = lessonView.findViewById(R.id.lesson_week);
TextView lesson_number = lessonView.findViewById(R.id.lesson_number);
TextView lesson_sumweek = lessonView.findViewById(R.id.lesson_sumweek); lesson_name.setText(lesson.getLesson_name());
teacher_name.setText(lesson.getTeacher_name());
lesson_building.setText(lesson.getLesson_building());
lesson_classroom.setText(lesson.getLesson_classroom());
lesson_nature.setText(lesson.getLesson_nature());
lesson_week.setText(lesson.getLesson_week());
lesson_number.setText(lesson.getLesson_number());
lesson_sumweek.setText(lesson.getLesson_sumweek()); return lessonView;
}
}

4.当然,适配之前应该需要相应的Javabean,这个应该放在前面,顺序错了,就不改了

public class LessonBean {
private String lesson_name;
private String teacher_name;
private String lesson_building;
private String lesson_classroom;
private String lesson_nature;
private String lesson_week;
private String lesson_number;
private String lesson_sumweek; public LessonBean(String number1,String number2,String number3,String number4,String number5,String number6,String number7,String number8)
{
lesson_name=number1;
teacher_name=number2;
lesson_building=number3;
lesson_classroom=number4;
lesson_nature=number5;
lesson_week=number6;
lesson_number=number7;
lesson_sumweek=number8;
} public String getLesson_name() {
return lesson_name;
} public void setLesson_name(String lesson_name) {
this.lesson_name = lesson_name;
} public String getTeacher_name() {
return teacher_name;
} public void setTeacher_name(String teacher_name) {
this.teacher_name = teacher_name;
} public String getLesson_building() {
return lesson_building;
} public void setLesson_building(String lesson_building) {
this.lesson_building = lesson_building;
} public String getLesson_classroom() {
return lesson_classroom;
} public void setLesson_classroom(String lesson_classroom) {
this.lesson_classroom = lesson_classroom;
} public String getLesson_nature() {
return lesson_nature;
} public void setLesson_nature(String lesson_nature) {
this.lesson_nature = lesson_nature;
} public String getLesson_week() {
return lesson_week;
} public void setLesson_week(String lesson_week) {
this.lesson_week = lesson_week;
} public String getLesson_number() {
return lesson_number;
} public void setLesson_number(String lesson_number) {
this.lesson_number = lesson_number;
} public String getLesson_sumweek() {
return lesson_sumweek;
} public void setLesson_sumweek(String lesson_sumweek) {
this.lesson_sumweek = lesson_sumweek;
}
}

  5.最后一步就是调用游标,读取数据然后添加到scrollview组件中的listview中

    public void test(String DB_PATH,String DB_NAME,String key)
{
// 下面测试 /data/data/com.test.db/databases/ 下的数据库是否能正常工作
SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(DB_PATH + DB_NAME, null);
Cursor cursor=null;
productList.clear();
if(key.isEmpty())
{
cursor = database.rawQuery("select 课程,教师,教学楼,教室,性质,星期,节次,周次 from lesson_informatization ", null);
}
else
{
cursor = database.rawQuery("select 课程,教师,教学楼,教室,性质,星期,节次,周次 from lesson_informatization where 课程 like '%"+key+"%'", null);
} ArrayList<LessonBean> list=new ArrayList<LessonBean>();
if(cursor.moveToFirst())
{
do{
String name=cursor.getString(cursor.getColumnIndex("课程"));
String teacher=cursor.getString(cursor.getColumnIndex("教师"));
String lesson_building=cursor.getString(cursor.getColumnIndex("教学楼"));
String lesson_classroom=cursor.getString(cursor.getColumnIndex("教室"));
String lesson_nature=cursor.getString(cursor.getColumnIndex("性质"));
String lesson_week=cursor.getString(cursor.getColumnIndex("星期"));
String lesson_number=cursor.getString(cursor.getColumnIndex("节次"));
String lesson_sumweek=cursor.getString(cursor.getColumnIndex("周次"));
productList.add(new LessonBean(name,teacher,lesson_building,lesson_classroom,lesson_nature,lesson_week,lesson_number,lesson_sumweek));
}while (cursor.moveToNext());
}
// if (cursor.getCount() > 0) {
// cursor.moveToFirst();
// try {
// // 解决中文乱码问题
// byte test[] = cursor.getBlob(0);
// String strtest = new String(test, "utf-8").trim();
// // 看输出的信息是否正确
// Log.d("是否能够查找到本地数据库的信息",strtest);
// System.out.println(strtest);
// } catch (UnsupportedEncodingException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
cursor.close();
if(productList.size()==0)
{
productList.add(new LessonBean("没有找到相关课程哦(ಥ_ಥ)","","","","","","",""));
}
}

java课程之团队开发冲刺阶段2.8的更多相关文章

  1. java课程之团队开发冲刺阶段1.7

    一.总结昨天进度 1.昨天学习了对数据库增删改查的基本操作,并且可以使用代码实现操作 二.遇到的问题 1.由于是学习阶段,没有遇到太大阻碍,但是最终需要实现的是联网进行数据库的读写或者是对本地数据库的 ...

  2. java课程之团队开发冲刺阶段1.4

    一.总结昨天进度 1.昨天任务全部完成 二.遇到的问题 1.对数据库的使用陌生 2.使用sqlite有些困难 3.对如何解决查询课程问题暂时没有找到好的解决方案 三.今日任务 1.由于周一的课程比较紧 ...

  3. java课程之团队开发冲刺阶段1.3

    一.总结昨天进度 1.完成任务指标,但是有些问题没有得到根本上解决,只是换方式解决了 2.使用时间:6小时 二.遇到的困难 1.在设置AlertDialog弹窗组件的时候,没有办法获取选中值,再实验多 ...

  4. java课程之团队开发冲刺阶段1.2

    一.总结昨天进度 1.三个任务都已经实现 2.使用时间:四个小时左右 二.遇到的困难 1.对Android原生的侧拉任务栏不了解,导致使用的时候出现了一部分问题 三.今天任务规划 1.对之前的程序重新 ...

  5. java课程之团队开发冲刺阶段2.10

    总结昨天任务: 1.已经完成修改APP等操作 遇到的困难: 1.在不同的Android版本中,APP的图标有出入 今天的任务: 最后一天,怀念一下,第二阶段结束了,课程也进入了尾声.

  6. java课程之团队开发冲刺阶段2.9

    总结昨天进度: 已经完成查询课程信息任务 遇到的困难: 已经全部解决 今天的任务: 修改APP图标 当日总结: manifest中管理着APP的基本信息资料,所以是在manifest文件中修改APP的 ...

  7. java课程之团队开发冲刺阶段2.7

    昨日总结: 1.完整实现课前闹钟提醒功能 遇到的困难: 1.没有遇到大的问题,细节地方没有处理好出现了一下小的情况 今天的任务: 1.实现对课程查询的完整实现 当日总结: 1.以前是使用二级联动下拉框 ...

  8. java课程之团队开发冲刺阶段2.4

    总结昨天进度: 1.照例学习了课前提醒的功能,不可否认的是,在这个功能上,需要的技术和之前的上课静音有点相似,都是通过广播然后开启service服务,然后进行每分钟的监听,查看时间是否一致,在一致的情 ...

  9. java课程之团队开发冲刺阶段1.6

    一.总结昨天进度 1.依照视频学习了sqlite,但是由于视频的不完整性导致并不知道代码的实际效果怎么样. 二.遇到的问题 1.依据上一条,在date目录下date文件夹中,的确发现了数据库的文件,但 ...

随机推荐

  1. 线程与IO

    pread/pwrite 定位和读取成为原子操作

  2. 87)PHP,PDO的预编译技术

    (1) 比如以下的语句: insert into biao1 values(‘李宁’,‘’): insert into biao1 values(‘安踏’,‘’): insert into biao1 ...

  3. JuJu团队1月2号工作汇报

    JuJu团队1月2号工作汇报 JuJu   Scrum 团队成员 今日工作 剩余任务 困难 飞飞 -- 测试dataloader 无 婷婷 调试代码 提升acc 无 恩升 -- 测试dataloade ...

  4. Stm32CubeMx lwip+freeRTOS TCP 服务

    如何添加lwip参照上一篇   stm32CubeMx lwip + freeRTOS 今天讲一下,如何添加TCP服务 LwIP 提供了三种编程接口,分别为 RAW/Callback API.NETC ...

  5. 云时代架构阅读笔记十五——之前碰到的Java面试题

    1.一个".java"源文件中是否可以包括多个类(不是内部类)?有什么限制? 可以有多个类,但只能有一个public的类,并且public的类名必须与文件名相一致. 2.Java有 ...

  6. 04.swoole学习笔记--webSocket服务器

    <?php //创建webSocket服务器 $serv=); //获取请求 //on //open 建立连接 $serv:服务器 $request:客户端信息 $serv->on('op ...

  7. 005.Oracle数据库 , 查询多字段连接合并,并添加文本内容

    /*Oracle数据库查询日期在两者之间*/ SELECT PKID , OCCUR_DATE, PKID || ' 曾经沧海难为水 ' ||TO_CHAR( OCCUR_DATE, ' yyyy/m ...

  8. POJ 3468 区间更新(求任意区间和)A Simple Problem with Integers

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 163977 ...

  9. redisTemplate注入为空

    springboot2.*集成redis时,redis工具类中的redisTemplate注入后总是为空. 问题代码还原: 1.工具类定义成静态工具类,@Resource注入redisTemplate ...

  10. Mac 配置代码高亮 Git状态显示

    Mac 一个为开发者量身定做的笔记本,分享给大家希望能帮助大家配置一个好的开发环境,好的开发环境才有好的心情Code. 首先进入到Home到目录一般默认打开的都是Home,如果不是输入 cd ~ 回车 ...