安卓课程表课程设计报告范本模板Word文件下载.docx
《安卓课程表课程设计报告范本模板Word文件下载.docx》由会员分享,可在线阅读,更多相关《安卓课程表课程设计报告范本模板Word文件下载.docx(16页珍藏版)》请在冰豆网上搜索。
12
成绩
一、目的(本次课程设计的概要以及所涉及的知识点.)
1.课程表课程的添加与实现
2.记录笔记并可以查看
设计知识点:
数据库的数据的新增,查询,删除等,辅助类,上下文菜单的使用;
二、使用环境(本次实践所使用的平台和相关软件。
)
SDK:
(softwaredevelopmentkit)软件开发工具包。
被软件开发工程师用于为特定的软件包、软件框架、硬件平台、操作系统等建立应用软件的开发工具的集合。
因此,AndroidSDK指的是Android专属的软件开发工具包。
使用Eclipse进行android应用开发需要给Eclipse装ADT插件,这样Eclipse就可以和androidADT建立连接,可以在Eclipse中启动android模拟器进行程序调试等。
三、内容与设计思想
(1.设计思路2.主要功能说明3.主要的模块结构4.主要代码分析.)
1.课程与笔记是私有的,所以设置用户名与密码登陆,在课程表中应有一个显示界面,用于显示已添加的课程,点击新增按钮进入新增界面,用于增加新的课程,需添加上课的星期和课的节次,并检查当前是否有课,并提示。
保存后进入课表显示界面,查看课表。
笔记中有一笔记列表,显示创建笔记的时间和标题。
点开笔记可以查看详细内容.也可以进行笔记的新增.若长按笔记。
则可以进行删除操作。
2。
登录进入菜单,若无用户,可以注册.
课程表,查看已经有课程,新增课程并保存。
笔记,查看已有笔记,查看详细笔记,新增笔记,删除笔记.
3。
整个程序包含两个大的模块:
课程表模块和笔记模块;
课程表中包含显示和新增两个模块;
笔记中有显示列表模块,新增模块,和查看模块
4.
(1)用户登录时,根据用户名与密码进入数据库中查询,若有返回值为1,表示有该用户,进行界面的跳转,进去菜单界面.若返回值为0,则表示用户名或密码错误,并提示.
but_login。
setOnClickListener(newOnClickListener(){
publicvoidonClick(Viewarg0){
Stringputname=edit_putname。
getText().toString();
Stringputpassword=edit_putpassword。
getText().toString();
Cursorcs=dbhelper。
login(putname,putpassword);
intm=cs.getCount();
if(m==0){
Stringtips=”你输入的用户名或密码有误"
;
Toasttoast=Toast。
makeText(getApplicationContext(),tips,20000);
toast.show();
}else{
Intentintent=newIntent(MainActivity。
this,MenuActivity。
class);
intent。
putExtra(”name”,putname);
MainActivity.this。
startActivity(intent);
}
}
});
(2)新增课程时,查询这一天的所有课程,若已有的课程和添加的课程节次相同则冲突,则提示这节已经有课,若无可进行添加,并跳转会课程表界面查看
Cursorcs=db.query(”schedule"
newString[]{”time"
},”day='
"
+day+"
’"
,null,null,null,null);
cs.moveToFirst();
while(!
cs。
isAfterLast()){
Stringcheck=cs.getString(cs.getColumnIndex(”time”));
if(check.equals(timeclass)){
Stringtips="
这节已经有课"
Toasttoast=Toast。
makeText(getApplicationContext(),tips,20000);
toast.show();
return;
}
cs.moveToNext();
cs。
close();
Stringsql="
insertintoschedule(’couesename’,’room'
,'
week’,'
day'
'
time'
,’teachername'
)”+
"
values('
+couesename+"
’,’”+room+”’,’”+week+”’,’"
’,’"
+timeclass+”'
’"
+teachername+"
'
)"
;
db。
execSQL(sql);
(3)通过上下文菜单的方法,长按笔记列表,会出现设置好删除菜单,通过onContextItemSelected响应菜单,并获得所选择的菜单。
通过info。
targetView
查找到长按的视图,并获得TextView里的时间字符串,根据字符串进入数据库进行查找并删除,再跟新listView;
this。
registerForContextMenu(lv_notes);
publicvoidonCreateContextMenu(ContextMenumenu,Viewv,
ContextMenuInfomenuInfo){
menu。
add(0,1,0,"
删除”);
}
publicbooleanonContextItemSelected(MenuItemitem){
AdapterContextMenuInfoinfo=(AdapterContextMenuInfo)item。
getMenuInfo();
if(item。
getItemId()==1){
//获取当前的视图
TextViewtv=(TextView)info.targetView.findViewById(R。
id。
tv_showwritetime);
Stringstr=tv.getText().toString();
Stringsql="
deletefromnoteswherewritetime=’”+str+”'
”;
db.execSQL(sql);
//通知更新显示ListV
cs=db.query(”notes”,newString[]{"
_id"
"
writetime”,"
notesname”},null,null,null,null,null,null);
adapter=newSimpleCursorAdapter(this,R.layout.notes_layout,cs,
newString[]{"
writetime"
,”notesname"
},
newint[]{R。
id.tv_showwritetime,R。
tv_shownotesname});
lv_notes.setAdapter(adapter);
//adapter。
notifyDataSetChanged();
}
returnfalse;
}
(4)新建了一个DBHelper辅助类继承SQLiteOpenHelper,新建数据库,新建表格,并对数据进行增删改查.onCreate()方法是建立表格,只进行一次。
还可以根据版本号进行数据库的更新,在其他类中调用查询方法,并返回所查询的值。
publicclassDBHelperextendsSQLiteOpenHelper{
privatestaticfinalintVersion=1;
privatestaticfinalStringDBNAME=”cc”;
privatestaticfinalStringsql_createschedule="
createtableschedule(_idintegerprimarykeyautoincrement,"
+"
couesenametext,”+”roomtext,”+”weektext,"
+
"
daytext,"
timetext,"
teachernametext)”;
privatestaticfinalStringsql_createuserinformation="
createtableuserinformation(_idintegerprimarykeyautoincrement,"
+”nametext,"
passwordtext,”+”imageidinteger)"
privatestaticfinalStringsql_createnotes=”createtablenotes(_idintegerprimarykeyautoincrement,”+”writetimetext,"
+”notesnametext,"
notestext)”;
publicDBHelper(Contextcontext){
super(context,DBNAME,null,Version);
publicvoidonCreate(SQLiteDatabasedb){
db.execSQL(sql_createschedule);
db.execSQL(sql_createuserinformation);
db。
execSQL(sql_createnotes);
publicvoidonUpgrade(SQLiteDatabasearg0,intarg1,intarg2){
publicCursorlogin(Stringputname,Stringputpassword){
SQLiteDatabasedb=this.getReadableDatabase();
Cursorcslogin=db。
query(”userinformation"
,null,”name=’"
+putname+"
andpassword='
+putpassword+”'
,null,null,null,null,null);
returncslogin;
publicvoidaegister(Stringnewname,Stringnewpassword,intimageid){
SQLiteDatabasedb=this.getReadableDatabase();
insertintouserinformation('
name’,’password'
imageid'
”values(’”+newname+"
’,’"
+newpassword+"
’,'
”+imageid+"
’)”;
db.execSQL(sql);
publicCursorcheckname(Stringnewname){
Cursorcscheckname=db.query(”userinformation"
newString[]{"
name"
},"
name='
+newname+"
”,null,null,null,null,null);
returncscheckname;
publicCursorqueryschedule(){
SQLiteDatabasedb=this。
getReadableDatabase();
Cursorcsschedule=db。
query("
schedule"
,null,null,null,null,null,null);
returncsschedule;
publicvoidaddcosuses(Stringcouesename,Stringroom,Stringweek,Stringday,Stringtimeclass,Stringteachername){
insertintoschedule(’couesename'
room’,’week’,'
teachername’)”+"
”+room+”'
,’"
+week+"
”+day+”'
’”+teachername+”’)"
publicvoidwritenotes(Stringwritetime,Stringnotesname,Stringnotes){
Stringsql=”insertintonotes(writetime,notesname,notes)values('
+writetime+”'
’”+notesname+”'
,’”+notes+"
execSQL(sql);
publicCursorquerynotes(){
Cursorcs=db.query("
notes”,newString[]{”_id”,"
”notesname”},null,null,null,null,null,null);
returncs;
}
四、调试过程(测试结果分析)
1.若无用户点击注册,进行注册,注册界面需要输入两次密码,进行密码确认.
注册后进入登录界面,经过用户名和密码验证过后进行登录进去菜单界面
进入菜单界面,选择相应的功能
4。
选择课表后,进去课表界面,可以查看已有的课程,课程表可以滑动,点击新增,进入新增界面进行增加
5.进入新增后输入课程名教室等,若无冲突,点击勾就保存进入课表界面,查看课表
6。
进入笔记列表界面,若点击笔记,则可以查看该篇详细笔记,若长按,通过上下文菜单的方法进行删除,点击笔记按钮,则可进入写笔记界面
7。
进入新增笔记界面,获取当前的时间,并记录,方便查询。
8。
点击笔记查看详细的笔记。
五、总结
1.设计中遇到的问题及解决过程
遇到了一些方法使用错误,通过网上的查找和询问高手解决的.
2.设计中产生的错误及原因分析
界面跳转是出现问题,经过排查后发现传递的参数有错。
3.设计体会和收获.
深深的感觉自己的知识经验匮乏。
虽然经常会报错,但是要慢慢的细心的排查,而且每天都要坚持写下去。
要不断的学习,遇到难题,不会的,要咬着牙把它啃下了。
六、附录
1、原代码节略
2、参考文献