基于android平台“每日一句”应用的设计与实现 - 图文(6)

2025-08-05

兰州大学本科生毕业论文 基于android平台“每日一句”应用的设计与实现

connect = new SqliteDBConnect(getApplicationContext()); db = connect.getReadableDatabase(); sqlManage = new SQLManage(); manage = ActivityManager.getInstance(); manage.addActivity(this);

ButtonClick click = new ButtonClick();

btnAddNewText = (Button)this.findViewById(R.id.btnAddNewText1); btnSearch = (Button)this.findViewById(R.id.btnSearch1); btnAllNote = (Button)this.findViewById(R.id.btnAll1); btnReturn = (Button)this.findViewById(R.id.btnReturn1); btnSearch.setOnClickListener(click); btnAllNote.setOnClickListener(click); btnAddNewText.setOnClickListener(click); btnReturn.setOnClickListener(click); //关键字查询搜索的文本输入框

txtBlur = (EditText)this.findViewById(R.id.search_Content1); listview = (ListView) findViewById(R.id.listview1); connect = new SqliteDBConnect(ShowTextList.this); readFile();

disPlay();//从数据库提取数据并显示

listview.setOnItemClickListener(new OnItemClickListener() {

public void onItemClick(AdapterView arg0, View arg1, int arg2, }

20

long arg3) {

Object>

map

=

(Map

Object>)

@SuppressWarnings(\Map

arg0.getItemAtPosition(arg2);

Intent intent = new Intent();

intent.putExtra(\intent.putExtra(\

intent.setClass(ShowTextList.this, DisPlay.class);

overridePendingTransition(R.anim.left_in, R.anim.left_out); startActivity(intent); finish();

兰州大学本科生毕业论文 基于android平台“每日一句”应用的设计与实现

});

listview.setOnItemLongClickListener(new OnItemLongClickListener() {

public boolean onItemLongClick(AdapterView arg0, View arg1,

int arg2, long arg3) { @SuppressWarnings(\

final Map map = (Map) arg0

.getItemAtPosition(arg2);

AlertDialog.Builder adb = new Builder(ShowTextList.this); adb.setTitle(map.get(\adb.setItems(new String[] { \删 除\修 改\

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,

int which) { switch (which) { case 0:

SQLiteDatabase

sdb

=

connect.getReadableDatabase();

sdb.delete(\Toast.makeText(ShowTextList.this, \删除sdb.close(); disPlay(); break;

Intent intent = new Intent(); intent.putExtra(\

intent.putExtra(\intent.setClass(ShowTextList.this, overridePendingTransition(R.anim.left_in,

21

{ map.get(\成功\

case 1:

map.get(\

DisPlay.class); R.anim.left_out);

兰州大学本科生毕业论文 基于android平台“每日一句”应用的设计与实现

}

});

}

});

}

}

startActivity(intent); finish(); break;

adb.show(); return false;

public void readFile(){

SharedPreferences myPrefs = getPreferences(MODE_PRIVATE); boolean hasPreferences = myPrefs.getBoolean(INITIALIZED, false); if(hasPreferences) { } else{

Resources myResources=getResources(); InputStream

Scanner scanner = new Scanner(myFile); while(scanner.hasNextLine()){

String line = scanner.nextLine(); String[]data1=line.split(\int x=data1.length; SqliteDBConnect

sd

=

new

myFile=myResources.openRawResource(R.raw.resource);//cet4为一个TXT文件

SqliteDBConnect(ShowTextList.this);

sqlDB = sd.getReadableDatabase(); name = data1[1].trim(); content = data1[3].trim();

time = \

name,

content,

category=1;

sqlManage.Insert(sqlDB,

22

time,category);

兰州大学本科生毕业论文 基于android平台“每日一句”应用的设计与实现

}

SQLiteDatabase sdb = connect.getReadableDatabase(); count = 0;

Cursor c1 = sdb.query(\}, null, null, null, null, \while (c1.moveToNext()) { } c1.close();

Cursor c = sdb.query(\\

null, null, \

List> list = new ArrayList

Map map = new HashMap(); String strName = c.getString(c.getColumnIndex(\//后期再修改成超过一行就加入\if (strName.length() > 15) {

map.put(\?\

23

Editor editor = myPrefs.edit(); editor.putBoolean(INITIALIZED, true); editor.commit();

}

public void disPlay() {

int noteid = c1.getInt(c1.getColumnIndex(\if (noteid > count)

count = noteid;

Object>>();

} else {

兰州大学本科生毕业论文 基于android平台“每日一句”应用的设计与实现

}

}

}

map.put(\

map.put(\list.add(map);

c.close(); sdb.close(); if (count > 0) { }

adapter

=

new

SimpleAdapter(ShowTextList.this,

list,

R.layout.text_item,

new String[] {\

R.id.noteName });

listview.setAdapter(adapter);

class ButtonClick implements View.OnClickListener {

private static final String TAG = \public void onClick(View v) {

if(v.getId()==R.id.btnAddNewText1) { }

//搜索按钮的事件处理

24

Intent intent = new Intent();

intent.setClass(ShowTextList.this, AddNewText.class); overridePendingTransition(R.anim.left_in, R.anim.left_out); startActivity(intent); finish();


基于android平台“每日一句”应用的设计与实现 - 图文(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:高三地理原因分析及影响因素类(教师版) - 图文

相关阅读
本类排行
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 7

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219