www.日本精品,久久中文视频,中文字幕第一页在线播放,香蕉视频免费网站,老湿机一区午夜精品免费福利,91久久综合精品国产丝袜长腿,欧美日韩视频精品一区二区

日記app安卓

發(fā)布時(shí)間:2017-01-18 來源: 日記大全 點(diǎn)擊:

日記app安卓篇一:基于android的日記本開發(fā)

西南科技大學(xué) 課程設(shè)計(jì)報(bào)告

課程名稱: 軟件設(shè)計(jì)基礎(chǔ)設(shè)計(jì)名稱: 基于android的日記本開發(fā)姓 名:學(xué) 號(hào): 班 級(jí): 通信1003班 指導(dǎo)教師:起止日期: 11.28——12.12

西南科技大學(xué)信息工程學(xué)院制

方 向 設(shè) 計(jì) 任 務(wù) 書

學(xué)生班級(jí): 通信1003班 學(xué)生姓名:學(xué)號(hào):

設(shè)計(jì)名稱:基于android的日記本開發(fā) 起止日期: 11.28——12.12指導(dǎo)教師:

方 向 設(shè) 計(jì) 學(xué) 生 日 志

2

基于android的日記本開發(fā)

一、 摘要(150-250字)

伴隨著無線移動(dòng)設(shè)備的迅速發(fā)展,手機(jī)的日益普及成為主流,在這一關(guān)鍵時(shí)期,Android系統(tǒng)的推出使手機(jī)發(fā)展進(jìn)入了一個(gè)新的領(lǐng)域。世界上一些知名移動(dòng)設(shè)備生產(chǎn)廠商對(duì)于Android智能機(jī)的開發(fā)熱情日益提高,Android系統(tǒng)的使用人群正在急速提升,Android應(yīng)用程序的多樣化使人們從手機(jī)中獲得更多樂趣,方便著人們的生活,使Android得到了社會(huì)越來越多的認(rèn)同。本次設(shè)計(jì)主要描述了基于android開發(fā)一個(gè)簡(jiǎn)易日記本的技術(shù)方法。

關(guān)鍵字:Android; DbAdapter;Activity;diary 二、 設(shè)計(jì)目的和意義

在中國(guó),手機(jī)已經(jīng)成為人們?nèi)粘I畋夭豢缮俚囊徊糠,智能手機(jī)在高校人群中逐漸得到了普及,Android手機(jī)憑借其優(yōu)秀的系統(tǒng)性能以及良好的用戶體驗(yàn)迅速得到了高校師生的青睞。在高校中,上課并不像高中時(shí)期有固定的教室和固定的時(shí)間,高校課程種類繁多,并且上課地點(diǎn)和時(shí)間不固定,一周內(nèi)極少會(huì)出現(xiàn)重復(fù)課程,所以要將課程表完整的記憶下來是一項(xiàng)很艱難的事情,很多同學(xué)不得不隨身攜帶一張課表來防止遺忘上課,但是還是不能完全避免該問題的發(fā)生,同時(shí),作為一個(gè)當(dāng)今高速發(fā)展的時(shí)代的成員,適應(yīng)這個(gè)社會(huì)是必不能少的,在各種社交場(chǎng)合中,記住一些必須的信息很重要,而它們往往又繁瑣又多,不易人為記住;谶@些問題,有必要設(shè)計(jì)一款方便小巧的簡(jiǎn)易日記本程序,可以讓用戶自定義文件,記住上課時(shí)間和地點(diǎn),從而避免遺忘上課的事情出現(xiàn),同時(shí)記住那些瑣碎卻有意義的小信息。而且,由于android系統(tǒng)市場(chǎng)的開放性和服務(wù)免費(fèi),它的應(yīng)用程序方面就成了一塊非常大的市場(chǎng),。 三、 設(shè)計(jì)原理

用戶在第一次進(jìn)入程序時(shí)會(huì)看到到一個(gè)日記本的主界面,可進(jìn)行日記文件的新建和刪除操作,按menu鍵可以選擇“幫助”和“退出”,程序主界面使用course_activity.java展示記錄,從Diary_activity, DiaryEditActivity類中可以新建和刪除日記信息,并在主界面中顯示。程序的配置信息主要存在DbAdapter中,該信息在數(shù)據(jù)顯示時(shí)讀取必要的配置信息,在按鈕監(jiān)聽函數(shù)中監(jiān)聽系統(tǒng)時(shí)間變化用來實(shí)現(xiàn)日記的創(chuàng)建功能。BaseColumns 是一個(gè)接口,里邊有兩個(gè)變量,一個(gè)是_ID="_id",一個(gè)是_COUNT="_ count" 。在Android當(dāng)中,每一個(gè)數(shù)據(jù)庫表至少有一個(gè)字段,而且這個(gè)字段是_id。所以當(dāng)我們構(gòu)造列名的輔助類時(shí),直接實(shí)現(xiàn)BaseColumns ,這樣我們便默認(rèn)地?fù)碛辛薩id字段。在我們的日記本的數(shù)據(jù)表里,一共有4個(gè)字段,分別是:"id"、"title"、"body"、"created"。在Android中鼓勵(lì)使用內(nèi)部類,這樣不但使用方便,而且執(zhí)行效率也高是請(qǐng)求數(shù)據(jù)的類型,例如,在例子當(dāng)中定義的類型是diary。當(dāng)然這一部分可以是0個(gè)片段或者多個(gè)片段構(gòu)成,如果Content Provider只是暴露出了一種類型的數(shù)據(jù),那么這部分可以為空,但是如果暴露出了多種,尤其是包含子類的時(shí)候,就不能為空,"1"這部分是允許為空的,如果為空,表示請(qǐng)求全部數(shù)據(jù);如果不為空,表示請(qǐng)求特定ID的數(shù)據(jù)。DatabaseHelper是操作數(shù)據(jù)庫的輔助類,通過這個(gè)類我們可以生成數(shù)據(jù)庫,并且維護(hù)這個(gè)數(shù)據(jù)庫。 在DiaryContentProvider中,我們定義了一些變量和常量,其中這些常量主要是描述數(shù)據(jù)庫的信息。在刪除方法中,rowId = uri.getPathSegments().get(1)負(fù)責(zé)得到rowId的值。 getPathSegments()方法得到一個(gè)string的list, db.delete(DIARY_TABLE_NAME, DiaryColumns.

日記app安卓

_ID + "=" + rowId, null)是標(biāo)準(zhǔn)的SQLite刪除操作。update()是更新一條數(shù)據(jù)的方法, 使用ContentProvider時(shí)首先得到SQLiteDatabase,然后得到rowId,最后再調(diào)用db.update(DIARY_ TABLE_NAME, values, DiaryColumns._ID + "="+ rowId, null)語句執(zhí)行更新工作。

3

其主要流程圖如下:

功能模塊:

四、 詳細(xì)設(shè)計(jì)步驟

簡(jiǎn)易日記本應(yīng)該具有日記本的基本功能,比如新建,編輯,刪除,保存等,從這幾方面初步想到應(yīng)該有一個(gè)主類負(fù)責(zé)調(diào)用其他負(fù)責(zé)實(shí)現(xiàn)功能的類,這樣整個(gè)程序會(huì)比較清晰,通過流程分析和可行性分析之后我開始查閱資料編寫程序,本程序主要由六個(gè)類組成,它們分別為Dbadapter,help-activity,lookDiary,MainActivity,diary-activity和DiaryEditActivity ,

1.其中MainActivity類為整個(gè)應(yīng)用的主Activity,其主要方法如下:

? onCreate:Activity主要重寫方法之一,實(shí)現(xiàn)程序初始化和界面展示; ? find_and_modify_button:尋找并點(diǎn)擊按鈕; ? onClick(View v):點(diǎn)擊當(dāng)前所選按鈕;

? onCreateOptionMenu:實(shí)現(xiàn)Option菜單的創(chuàng)建;

? onOptionsItemSelected:實(shí)現(xiàn)菜單項(xiàng)的點(diǎn)擊事件響應(yīng);

界面設(shè)計(jì)方面通過RelativeLayout實(shí)現(xiàn)布局,使用了TextView,ImageButton文件列表通

4

過ListView實(shí)現(xiàn)界面展示。該類通過繼承ListActivity類,用來顯示ListView中的數(shù)據(jù)并實(shí)現(xiàn)對(duì)ListView上ImageView控件點(diǎn)擊的統(tǒng)一響應(yīng)。 其主要代碼:public class MainActivity extends Activity

{//菜單選項(xiàng)

public static final int HELP = Menu.FIRST; public static final int EXIT = Menu.FIRST + 1; /** Called when the activity is first created. */

public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);setTitle("小小日記本");find_and_modify_button();

Toast.makeText(MainActivity.this,

"歡迎使用簡(jiǎn)易日記本", Toast.LENGTH_SHORT).show(); } private void find_and_modify_button() {// TODO Auto-generated method stubButton btn_diary = (Button) findViewById(R.id.btn_diary);btn_diary.setOnClickListener(diary_listener); } private Button.OnClickListener diary_listener = new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(); intent.setClass(MainActivity.this, diary_activity.class); startActivity(intent);} } /** menu.findItem(EXIT_ID);找到特定的MenuItem* MenuItem.setIcon.可以設(shè)置menu按鈕的背景*/ public boolean onCreateOptionsMenu(Menu menu) {super.onCreateOptionsMenu(menu);menu.add(0, HELP, 0, "幫助").setIcon(R.drawable.helps);menu.add(0, EXIT, 0, "退出").setIcon(R.drawable.exit);return true; } public boolean onOptionsItemSelected(MenuItem item) {switch (item.getItemId()) {case HELP:Intent help_intent = new Intent(); help_intent.setClass(MainActivity.this, help_activity.class); startActivity(help_intent);break;case EXIT:

5

日記app安卓篇二:android日記本代碼

一、實(shí)驗(yàn)詳細(xì)代碼

(1) 布局的代碼

a. edit.xml代碼

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

<LinearLayout android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="wrap_content">

<TextView android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="主題"

android:padding="2px" />

<EditText android:id="@+id/title"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1" />

</LinearLayout>

<TextView android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="內(nèi)容" />

<EditText android:id="@+id/body"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_weight="1"

android:scrollbars="vertical" android:gravity="top" />

<Button android:id="@+id/confirm" android:text="確定"android:layout_width="wrap_content"

android:layout_height="wrap_content" />

</LinearLayout>

b. list.xml的代碼

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content"

android:layout_height="wrap_content">

<ListView android:id="@+id/android:list"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

<TextView android:id="@+id/android:empty"

android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="按下MENU寫日記!" />

</LinearLayout>

c. row.xml的代碼

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout android:id="@+id/row"

xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"

android:layout_height="fill_parent">

<TextView android:id="@+id/text1"

android:layout_width="wrap_content"

android:layout_height="30px"

android:maxWidth="200dip"

android:textSize="22sp"

android:layout_marginTop="10dip"

android:text="第1組第1項(xiàng)" />

<TextView android:id="@+id/created"

android:layout_width="wrap_content"

android:layout_height="35px"

android:layout_alignParentRight="true"

android:layout_marginLeft="10dip"

android:layout_marginTop="10dip"

android:text="2011年10月30日" />

</RelativeLayout>

(2) 主要程序代碼

a. DiaryBookDemo代碼

public class DiaryBookDemo extends ListActivity {

private static final int ACTIVITY_CREATE = 0;

private static final int ACTIVITY_EDIT = 1;

private static final int INSERT_ID = Menu.FIRST;

private static final int DELETE_ID = Menu.FIRST + 1;

private DiaryDbAdapter mDbHelper;

private Cursor mDiaryCursor;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.list);

mDbHelper = new DiaryDbAdapter(this);

mDbHelper.open();

renderListView();

startService(new Intent(this, TimerServer.class)); }

private void renderListView() {

mDiaryCursor = mDbHelper.getAllNotes();

startManagingCursor(mDiaryCursor);

String[] from = new String[] { DiaryDbAdapter.KEY_TITLE, DiaryDbAdapter.KEY_CREATED };

int[] to = new int[] { R.id.text1, R.id.created };

SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.row, mDiaryCursor, from, to);setListAdapter(notes);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

super.onCreateOptionsMenu(menu);

menu.add(0, INSERT_ID, 0, "插入");

menu.add(0, DELETE_ID, 0, "刪除");

return true;

}

@Override

public boolean onMenuItemSelected(int featureId, MenuItem item) {

switch (item.getItemId()) {

case INSERT_ID:

createDiary();

return true;

case DELETE_ID:

mDbHelper.deleteDiary(getListView().getSelectedItemId());

renderListView();

return true;

}

return super.onMenuItemSelected(featureId, item); }

private void createDiary() {

Intent i = new Intent(this, ActivityDiaryEdit.class);startActivityForResult(i, ACTIVITY_CREATE);

}

@Override

// 需要對(duì)position和id進(jìn)行一個(gè)很好的區(qū)分

// position指的是點(diǎn)擊的這個(gè)ViewItem在當(dāng)前ListView中的位置 // 每一個(gè)和ViewItem綁定的數(shù)據(jù),肯定都有一個(gè)id,通過這個(gè)id可以找到那條數(shù)據(jù)。

protected void onListItemClick(ListView l, View v, int position, long id) {

super.onListItemClick(l, v, position, id);

Cursor c = mDiaryCursor;

c.moveToPosition(position);

Intent i = new Intent(this, ActivityDiaryEdit.class);i.putExtra(DiaryDbAdapter.KEY_ROWID, id);

i.putExtra(DiaryDbAdapter.KEY_TITLE, c.getString(c

.getColumnIndexOrThrow(DiaryDbAdapter.KEY_TITLE)));

i.putExtra(DiaryDbAdapter.KEY_BODY, c.getString(c

.getColumnIndexOrThrow(DiaryDbAdapter.KEY_BODY)));

startActivityForResult(i, ACTIVITY_EDIT);

}

@Override

protected void onActivityResult(int requestCode, int resultCode,

Intent intent) {

super.onActivityResult(requestCode, resultCode, intent);renderListView();

}

}

b. ActivityDiaryEdit的代碼

public class ActivityDiaryEdit extends Activity {

private EditText mTitleText;

private EditText mBodyText;

private Long mRowId;

private DiaryDbAdapter mDbHelper;

@Override

protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);

mDbHelper = new DiaryDbAdapter(this);

mDbHelper.open();

setContentView(R.layout.edit);

mTitleText = (EditText) findViewById(R.id.title);mBodyText = (EditText) findViewById(R.id.body);

Button confirmButton = (Button)

findViewById(R.id.confirm);

mRowId = null;

// 每一個(gè)intent都會(huì)帶一個(gè)Bundle型的extras數(shù)據(jù)。Bundle extras = getIntent().getExtras();

if (extras != null) {

String title =

extras.getString(DiaryDbAdapter.KEY_TITLE);

String body =

extras.getString(DiaryDbAdapter.KEY_BODY);

mRowId = extras.getLong(DiaryDbAdapter.KEY_ROWID);

if (title != null) {

mTitleText.setText(title);

}

if (body != null) {

mBodyText.setText(body);

}

}

confirmButton.setOnClickListener(new

View.OnClickListener() {

public void onClick(View view) {

String title = mTitleText.getText().toString(); String body = mBodyText.getText().toString(); if (mRowId != null) {

mDbHelper.updateDiary(mRowId, title, body); } else

mDbHelper.createDiary(title, body); Intent mIntent = new Intent();

setResult(RESULT_OK, mIntent);

日記app安卓篇三:安卓開發(fā)實(shí)習(xí)_個(gè)人日志

中軟國(guó)際 長(zhǎng)沙ETC 實(shí) 習(xí) 實(shí) 訓(xùn) 日 志

相關(guān)熱詞搜索:日記 app 日本appstore有安卓嗎 妹調(diào)日記安卓

版權(quán)所有 蒲公英文摘 www.newchangjing.com