自己做的android小程序适合学习一两个月的同学本人就是.docx

上传人:b****3 文档编号:4017403 上传时间:2023-05-06 格式:DOCX 页数:14 大小:337.40KB
下载 相关 举报
自己做的android小程序适合学习一两个月的同学本人就是.docx_第1页
第1页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第2页
第2页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第3页
第3页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第4页
第4页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第5页
第5页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第6页
第6页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第7页
第7页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第8页
第8页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第9页
第9页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第10页
第10页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第11页
第11页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第12页
第12页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第13页
第13页 / 共14页
自己做的android小程序适合学习一两个月的同学本人就是.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

自己做的android小程序适合学习一两个月的同学本人就是.docx

《自己做的android小程序适合学习一两个月的同学本人就是.docx》由会员分享,可在线阅读,更多相关《自己做的android小程序适合学习一两个月的同学本人就是.docx(14页珍藏版)》请在冰点文库上搜索。

自己做的android小程序适合学习一两个月的同学本人就是.docx

自己做的android小程序适合学习一两个月的同学本人就是

WelcomeActivity欢迎界面

packageyour.login.namespace;

importjava.util.HashMap;

importandroid.app.Activity;

importandroid.content.Context;

importandroid.content.Intent;

importandroid.database.Cursor;

importandroid.os.Bundle;

importandroid.util.Log;

importandroid.view.View;

importandroid.widget.Button;

importandroid.widget.EditText;

importandroid.widget.SimpleCursorAdapter;

importandroid.widget.TextView;

importandroid.widget.Toast;

publicclasswelcomeActivityextendsActivityimplements

android.view.View.OnClickListener{

@Override

protectedvoidonCreate(BundlesavedInstanceState){

//TODOAuto-generatedmethodstub

super.onCreate(savedInstanceState);

setContentView(R.layout.welcome);

TextViewtextView1=(TextView)findViewById(R.id.textView1);

textView1.setText("欢迎你,小朋友!

");

Buttonb2=(Button)findViewById(R.id.b2);

b2.setOnClickListener(this);

fillData();

}

privateLoginDbAdaptermdbhelper;

privateCursormcursor;

privateHashMapmmap=newHashMap();

privateinsertDBgh;

privatevoidfillData(){

mdbhelper=newLoginDbAdapter(this);

mdbhelper.open();

gh=newinsertDB(mdbhelper);

gh.insert();

mcursor=mdbhelper.getall();

startManagingCursor(mcursor);

/*1.这个方法使用的前提是:

游标结果集里有很多的数据记录。

所以,在使用之前,先对Cursor是否为null进行判断,如果Cursor!

=null,再使用此方法

2.如果使用这个方法,最后也要用stopManagingCursor()来把它停止掉,以免出现错误。

3.使用这个方法的目的是把获取的Cursor对象交给Activity管理,这样Cursor的生命周期便能和Activity自动同步,

省去自己手动管理。

*/

while(!

mcursor.isLast()){

mcursor.moveToNext();

mmap.put(mcursor.getString

(1),mcursor.getString

(2));

}

}

@Override

publicvoidonClick(Viewv){

//TODOAuto-generatedmethodstub

EditTexted3=(EditText)findViewById(R.id.ed3);

Bundlebundle=null;

if(mmap.get(ed3.getText().toString())!

=null){

bundle=newBundle();

bundle.putString("ctx",mmap.get(ed3.getText().toString()));

Intenti=newIntent();

i.putExtras(bundle);

i.setClass(welcomeActivity.this,textActivity.class);

startActivity(i);

}else//if(!

mcursor.getString

(1).equals(ed3.getText().toString()))

Toast.makeText(this,"不存在",3000).show();

ed3.setText("");

}

}

LoginkuangActivity登录界面

packageyour.show.tt;

importjava.io.Serializable;

importjava.util.ArrayList;

importjava.util.HashMap;

importjava.util.List;

importjava.util.Set;

importandroid.app.Activity;

importandroid.content.Intent;

importandroid.database.Cursor;

import.Uri;

importandroid.os.AsyncTask;

importandroid.os.Bundle;

importandroid.util.Log;

importandroid.view.View;

importandroid.view.View.OnClickListener;

importandroid.widget.Button;

importandroid.widget.TextView;

publicclassShowttActivityextendsActivityimplementsOnClickListener{

privateButtonb1,b2,b3;

privateTextViewt1,t2;

privateHashMapmmap=newHashMap();

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

t1=(TextView)findViewById(R.id.t1);

b1=(Button)findViewById(R.id.b1);

b2=(Button)findViewById(R.id.b2);

b3=(Button)findViewById(R.id.b3);

t2=(TextView)findViewById(R.id.t2);

b1.setOnClickListener(this);

b2.setOnClickListener(this);

b3.setOnClickListener(this);

}

publicvoidonClick(Viewview){

switch(view.getId()){

caseR.id.b2:

IntentwebIntent=newIntent(Intent.ACTION_VIEW,

Uri.parse("

startActivity(webIntent);

break;

caseR.id.b1:

MyAsyncTasktask=newMyAsyncTask();

task.execute();

break;

caseR.id.b3:

Bundlebundle=newBundle();

bundle.putString("ctx","10");

Intentw=newIntent();

w.putExtras(bundle);

w.setClass(ShowttActivity.this,Zhejiang.class);

startActivity(w);

break;

}

}

classMyAsyncTaskextendsAsyncTask{

@Override

//doInBackground本身就是进程--可以调用Thread.sleep()方法

protectedVoiddoInBackground(Void...params){

try{

Thread.sleep(2000);

}catch(InterruptedExceptione){

//TODOAuto-generatedcatchblock

e.printStackTrace();

}

returnnull;

}

protectedvoidonPostExecute(Voidresult){

t2.setVisibility(View.VISIBLE);

super.onPostExecute(result);

}

}

}

textActivity显示的文本界面

packageyour.login.namespace;

importandroid.app.Activity;

importandroid.os.Bundle;

importandroid.widget.TextView;

publicclasstextActivityextendsActivity{

privateTextViewt3;

@Override

protectedvoidonCreate(BundlesavedInstanceState){

//TODOAuto-generatedmethodstub

super.onCreate(savedInstanceState);

setContentView(R.layout.context);

t3=(TextView)findViewById(R.id.t3);

Bundlebundle=this.getIntent().getExtras();

Stringqq=bundle.getString("ctx");

t3.setText(qq);

}

}

Adapater接口,实现数据库和数据映射

packageyour.login.namespace;

importandroid.content.ContentValues;

importandroid.content.Context;

importandroid.database.Cursor;

importandroid.database.SQLException;

importandroid.database.sqlite.SQLiteDatabase;

importandroid.database.sqlite.SQLiteOpenHelper;

publicclassLoginDbAdapter{

privateContextmCtx=null;

privateDatabaseHelperdbHelper;

privatestaticfinalStringDB_NAME="db_food";

privatestaticfinalStringTABLE_NAME="food";

privatestaticfinalintDB_VERSION=1;

privatestaticfinalStringCREATE_TABLE="createtablefood("

+"_idintegerprimarykeynotnull,"+"notetext,"+"createdstring"

+");";

privatestaticfinalStringDROP_TABLE="droptableifexists"

+TABLE_NAME;

SQLiteDatabasedb;

publicstaticfinalStringKEY_ROWID="_id";

publicstaticfinalStringKEY_NOTE="note";

publicstaticfinalStringKEY_CREATED="created";

privateinti=0;

publicLoginDbAdapter(Contextctx){

this.mCtx=ctx;

}

publicLoginDbAdapteropen()throwsSQLException{

dbHelper=newDatabaseHelper(mCtx);

db=dbHelper.getWritableDatabase();

returnthis;

}

publicvoidclose(){

dbHelper.close();

}

publicCursorgetall(){

//TODOAuto-generatedmethodstub

returndb.rawQuery("SELECT*fromfood",null);

}

publiclongcreate(Stringmtitle,Stringmcontext){

ContentValuescv=newContentValues();

cv.put(KEY_ROWID,i);//每create一次,时id+1

i++;

cv.put(KEY_NOTE,mtitle);

cv.put(KEY_CREATED,mcontext);

return(db.insert(TABLE_NAME,null,cv));

}

classDatabaseHelperextendsSQLiteOpenHelper{

publicDatabaseHelper(Contextcontext){

super(context,DB_NAME,null,DB_VERSION);

//TODOAuto-generatedconstructorstub

}

@Override

publicvoidonCreate(SQLiteDatabasedb){

//TODOAuto-generatedmethodstub

db.execSQL(CREATE_TABLE);

}

@Override

publicvoidonUpgrade(SQLiteDatabasedb,intoldVersion,intnewVersion){

//TODOAuto-generatedmethodstub

db.execSQL(DROP_TABLE);

onCreate(db);

}

}

}

packageyour.login.namespace;

publicclassinsertDB{

privateLoginDbAdapterll;

publicinsertDB(LoginDbAdapterl){

ll=l;

}

publicvoidinsert(){

longa=ll.create("aa","wew");

a=ll.create("bb","wewe");

a=ll.create("cc","wewew");

a=ll.create("张杰","张杰,生于成都,长于成都,骨子里有着四川人的乐观豁达与坚强隐忍。

而良好的家教,也赋予了他温润的性情与待人接物中的克己尊重,培养出看似质朴却将令他受益一生的品质:

真诚、谦虚、努力、孝顺。

很难想像,尽管以歌唱上的十项全能著称,尤以高音及英文歌曲见长,张杰却是毕业于四川师范大学旅游管理专业。

由一个和艺术专业相去甚远的非科班生,成长为内地歌坛一位不可多得的实力兼具偶像的歌手,除了嗓子等各种对唱歌有助益的身体条件上的天赋,还得益于张杰从小对于唱歌、舞蹈、各种乐器(电子琴,吉他,钢琴,架子鼓等)浓厚的兴趣,当然更加离不开他在钟爱的演艺事业中锐意进取,用汗水与毅力一次次超越自己,完成颠覆。

");

a=ll.create("谢娜","谢娜,中国著名多栖女艺人。

因与何炅、李维嘉等人共同主持湖南卫视综艺节目《快乐大本营》而成名,素有“内地综艺天后”之称。

以幽默诙谐的搞笑风格而著称,又被誉为大陆版周星驰。

2011年9月26日谢娜与内地著名流行歌手张杰在云南香格里拉举行了婚礼。

2012年7月,主持湖南卫视推出的国内首档明星模仿秀大赏赛《百变大咖秀》。

");

}

}

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2