安卓課程表課程設(shè)計報告_第1頁
安卓課程表課程設(shè)計報告_第2頁
安卓課程表課程設(shè)計報告_第3頁
安卓課程表課程設(shè)計報告_第4頁
安卓課程表課程設(shè)計報告_第5頁
已閱讀5頁,還剩12頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、課程設(shè)計實驗報告南 京 曉 莊 學(xué) 院【移動開發(fā)應(yīng)用框架】課程設(shè)計報告課程表的設(shè)計與實現(xiàn)所在院(系):信息工程學(xué)院學(xué) 號 : 13139173學(xué)生姓名 : 陳倡年級專業(yè) : 軟件工程指導(dǎo)教師 : 李青 提交日期 : 2015 年 12 月課程設(shè)計實驗報告班級 13軟工4姓名 陳倡學(xué)號 13139173任課教師李青實驗日期 2015.12成績一、 目的(本次課程設(shè)計的概要以及所涉及的知識點。)1.課程表課程的添加與實現(xiàn)2. 記錄筆記并可以查看設(shè)計知識點:數(shù)據(jù)庫的數(shù)據(jù)的新增,查詢,刪除等,輔助類,上下文菜單的使用;二、使用環(huán)境 (本次實踐所使用的平臺和相關(guān)軟件。 ) SDK:(software d

2、evelopment kit)軟件開發(fā)工具包。被軟件開發(fā)工程師用于為特定的軟件包、軟件框架、硬件平臺、操作系統(tǒng)等建立應(yīng)用軟件的開發(fā)工具的集合。因此,Android SDK 指的是Android專屬的軟件開發(fā)工具包。 使用Eclipse進行android應(yīng)用開發(fā)需要給Eclipse裝ADT插件,這樣Eclipse就可以和android ADT建立連接,可以在Eclipse中啟動android模擬器進行程序調(diào)試等。三、內(nèi)容與設(shè)計思想 (1 設(shè)計思路 2 主要功能說明 3 主要的模塊結(jié)構(gòu) 4 主要代碼分析 。 )1.課程與筆記是私有的,所以設(shè)置用戶名與密碼登陸,在課程表中應(yīng)有一個顯示界面,用于顯示已

3、添加的課程,點擊新增按鈕進入新增界面,用于增加新的課程,需添加上課的星期和課的節(jié)次,并檢查當(dāng)前是否有課,并提示。保存后進入課表顯示界面,查看課表。筆記中有一筆記列表,顯示創(chuàng)建筆記的時間和標(biāo)題。點開筆記可以查看詳細內(nèi)容。也可以進行筆記的新增。若長按筆記。則可以進行刪除操作。2.登錄進入菜單,若無用戶,可以注冊。課程表,查看已經(jīng)有課程,新增課程并保存。筆記,查看已有筆記,查看詳細筆記,新增筆記,刪除筆記。3.整個程序包含兩個大的模塊:課程表模塊和筆記模塊;課程表中包含顯示和新增兩個模塊;筆記中有顯示列表模塊,新增模塊,和查看模塊4.(1)用戶登錄時,根據(jù)用戶名與密碼進入數(shù)據(jù)庫中查詢,若有返回值為1

4、,表示有該用戶,進行界面的跳轉(zhuǎn),進去菜單界面。若返回值為0 ,則表示用戶名或密碼錯誤,并提示。but_login.setOnClickListener(new OnClickListener() public void onClick(View arg0) String putname = edit_putname.getText().toString();String putpassword = edit_putpassword.getText().toString();Cursor cs = dbhelper.login(putname, putpassword);int m = cs.g

5、etCount();if(m=0)String tips = "你輸入的用戶名或密碼有誤"Toast toast = Toast.makeText(getApplicationContext(), tips,20000); toast.show();elseIntent intent = new Intent(MainActivity.this,MenuActivity.class);intent.putExtra("name", putname);MainActivity.this.startActivity(intent););(2)新增課程時,查詢

6、這一天的所有課程,若已有的課程和添加的課程節(jié)次相同則沖突,則提示這節(jié)已經(jīng)有課,若無可進行添加,并跳轉(zhuǎn)會課程表界面查看Cursor cs = db.query("schedule", new String"time", "day='"+day+"'", null, null, null, null);cs.moveToFirst();while(!cs.isAfterLast()String check = cs.getString(cs.getColumnIndex("time"

7、);if(check.equals(timeclass)String tips = "這節(jié)已經(jīng)有課"Toast toast = Toast.makeText(getApplicationContext(), tips, 20000); toast.show(); return;cs.moveToNext();cs.close();String sql = "insert into schedule('couesename','room','week','day','time','

8、;teachername')" +" values('"+couesename+"','"+room+"','"+week+"','"+day+"','"+timeclass+"','"+teachername+"')"db.execSQL(sql);(3)通過上下文菜單的方法,長按筆記列表,會出現(xiàn)設(shè)置好刪除菜單,通過onContextItem

9、Selected響應(yīng)菜單,并獲得所選擇的菜單。通過info.targetView 查找到長按的視圖,并獲得TextView里的時間字符串,根據(jù)字符串進入數(shù)據(jù)庫進行查找并刪除,再跟新listView;this.registerForContextMenu(lv_notes);public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) menu.add(0, 1,0, "刪除");public boolean onContextItemSelected(MenuItem i

10、tem)AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();if(item.getItemId()=1)/獲取當(dāng)前的視圖TextView tv = (TextView)info.targetView.findViewById(R.id.tv_showwritetime);String str = tv.getText().toString();String sql = "delete from notes where writetime='"+str+"'

11、;"db.execSQL(sql);/通知更新顯示ListVcs = db.query("notes", new String"_id","writetime","notesname", null, null, null, null, null, null);adapter = new SimpleCursorAdapter(this, R.layout.notes_layout, cs,new String"writetime","notesname",new i

12、ntR.id.tv_showwritetime,R.id.tv_shownotesname);lv_notes.setAdapter(adapter);/adapter.notifyDataSetChanged();return false;(4) 新建了一個DBHelper輔助類繼承SQLiteOpenHelper,新建數(shù)據(jù)庫,新建表格,并對數(shù)據(jù)進行增刪改查。onCreate()方法是建立表格,只進行一次。還可以根據(jù)版本號進行數(shù)據(jù)庫的更新,在其他類中調(diào)用查詢方法,并返回所查詢的值。public class DBHelper extends SQLiteOpenHelperprivate st

13、atic final int Version = 1 ;private static final String DBNAME = "cc"private static final String sql_createschedule = "create table schedule(_id integer primary key autoincrement,"+" couesename text,"+" room text,"+"week text," +"day text,"

14、+"time text,"+"teachername text)"private static final String sql_createuserinformation = "create table userinformation(_id integer primary key autoincrement,"+" name text,"+" password text,"+"imageid integer)"private static final String sql

15、_createnotes = "create table notes(_id integer primary key autoincrement,"+"writetime text,"+"notesname text,"+"notes text)"public DBHelper(Context context) super(context, DBNAME, null, Version);public void onCreate(SQLiteDatabase db) db.execSQL(sql_createsche

16、dule);db.execSQL(sql_createuserinformation);db.execSQL(sql_createnotes);public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) public Cursor login(String putname,String putpassword)SQLiteDatabase db = this.getReadableDatabase();Cursor cslogin = db.query("userinformation",null,"

17、;name='"+putname+"' and password ='"+putpassword+"'",null,null,null,null,null);return cslogin;public void aegister(String newname,String newpassword,int imageid)SQLiteDatabase db = this.getReadableDatabase();String sql = "insert into userinformation('

18、;name','password','imageid')" +" values('"+newname+"','"+newpassword+"','"+imageid+"')"db.execSQL(sql);public Cursor checkname(String newname)SQLiteDatabase db = this.getReadableDatabase();Cursor cscheckname = d

19、b.query("userinformation", new String"name", "name = '"+newname+"'", null, null, null, null, null);return cscheckname;public Cursor queryschedule()SQLiteDatabase db = this.getReadableDatabase();Cursor csschedule = db.query("schedule", null, n

20、ull, null, null, null, null);return csschedule;public void addcosuses(String couesename,String room,String week,String day,String timeclass,String teachername)SQLiteDatabase db = this.getReadableDatabase();String sql = "insert into schedule('couesename','room','week',

21、9;day','time','teachername')" +" values('"+couesename+"','"+room+"','"+week+"','"+day+"','"+timeclass+"','"+teachername+"')"db.execSQL(sql);public void writenotes(String writetime,String notesname,String notes)SQLiteDatabase db = this.getReadableDatabase();String sql = "insert into notes(writetime,notesname,notes) values('"+writetime+"','"+notesname+"','"+notes+"')"db.execSQL(

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論