Android学生信息管理系统APP文档格式.docx

上传人:b****5 文档编号:16522430 上传时间:2022-11-24 格式:DOCX 页数:22 大小:24.29KB
下载 相关 举报
Android学生信息管理系统APP文档格式.docx_第1页
第1页 / 共22页
Android学生信息管理系统APP文档格式.docx_第2页
第2页 / 共22页
Android学生信息管理系统APP文档格式.docx_第3页
第3页 / 共22页
Android学生信息管理系统APP文档格式.docx_第4页
第4页 / 共22页
Android学生信息管理系统APP文档格式.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

Android学生信息管理系统APP文档格式.docx

《Android学生信息管理系统APP文档格式.docx》由会员分享,可在线阅读,更多相关《Android学生信息管理系统APP文档格式.docx(22页珍藏版)》请在冰豆网上搜索。

Android学生信息管理系统APP文档格式.docx

4、具体实现

1.主界面:

主界面显示所有功能,每个按钮点击后,跳转进入相应功能

核心代码:

publicclassMainextendsActivity{

SQLiteDatabasedb;

Buttonbtn_search;

Buttonbtn_modify;

Buttonbtn_add;

Buttonbtn_delete;

Buttonbtn_quit;

Buttonbtn_show;

@Override

protectedvoidonCreate(BundlesavedInstanceState){

requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(,;

super.onCreate(savedInstanceState);

setContentView(;

//打开数据库,若不存在,则创建

db=SQLiteDatabase.openOrCreateDatabase(this.getFilesDir().toString()+"

/Student.db3"

null);

btn_search=(Button)findViewById(;

btn_modify=(Button)findViewById(;

btn_add=(Button)findViewById(;

btn_delete=(Button)findViewById(;

btn_quit=(Button)findViewById(;

btn_show=(Button)findViewById(;

try

{

Cursorcursor=db.rawQuery("

select*fromstudent"

cursor.close();

}

catch(SQLiteExceptione)

db.execSQL("

createtablestudent"

+"

("

nameTEXT,"

NOTEXTPrimaryKey,"

sexTEXT,"

professionTEXT,"

ageTEXT"

)"

);

//显示所有数据按钮的功能实现

btn_show.setOnClickListener(newOnClickListener()

publicvoidonClick(Viewsource){

//获取指针

Cursorcursor=db.rawQuery("

//判断数据库是否不存在任何数据

if(cursor.moveToFirst()==false)

{

Toast.makeText(Main.this,"

不存在记录"

Toast.LENGTH_SHORT).show();

}

else

{

List<

Student>

p=newArrayList<

();

String>

re_name=newArrayList<

String[]>

info=newArrayList<

//保存搜索出的所有数据

for(cursor.moveToFirst();

!

cursor.isAfterLast();

cursor.moveToNext())

{

intnameColume=cursor.getColumnIndex("

name"

intNOColume=cursor.getColumnIndex("

NO"

intproColume=cursor.getColumnIndex("

profession"

intsexColume=cursor.getColumnIndex("

sex"

intageColume=cursor.getColumnIndex("

age"

Studentstudent=newStudent();

student.name="

姓名:

"

+cursor.getString(nameColume);

student.NO="

学号:

+cursor.getString(NOColume);

student.sex="

性别:

+cursor.getString(sexColume);

student.profession="

专业:

+cursor.getString(proColume);

student.age="

年龄:

+cursor.getString(ageColume);

p.add(student);

String[]temp=student.MakeString();

info.add(temp);

Stringnewname=cursor.getString(nameColume);

re_name.add(newname);

}

//对保存的数据进行封装

String[]Cur_name=newString[re_name.size()];

Cur_name=re_name.toArray(Cur_name);

String[][]Cur_info=newString[info.size()][];

Cur_info=info.toArray(Cur_info);

Bundlebundle=newBundle();

bundle.putStringArray("

Cur_name);

Studentdata=newStudent();

data.info=Cur_info;

//将封装的数据传递给结果界面的activity

Intentintent=newIntent(Main.this,SearchResult.class);

intent.putExtras(bundle);

intent.putExtra("

data"

data);

startActivity(intent);

cursor.close();

}

});

//为剩下的按钮绑定监听器实现跳转功能

btn_search.setOnClickListener(newOnClickListener()

Intentintent=newIntent(Main.this,Search.class);

startActivity(intent);

btn_modify.setOnClickListener(newOnClickListener()

Intentintent=newIntent(Main.this,Modify.class);

btn_add.setOnClickListener(newOnClickListener()

Intentintent=newIntent(Main.this,Add.class);

btn_delete.setOnClickListener(newOnClickListener()

Intentintent=newIntent(Main.this,Delete.class);

btn_quit.setOnClickListener(newOnClickListener()

db.close();

finish();

}

}

2.数据显示界面:

按姓名排列,点击条目展开具体信息

publicclassSearchResultextendsActivity

{

@SuppressLint("

RtlHardcoded"

publicvoidonCreate(BundlesavedInstanceState)

{

//获取传送来的数据

finalIntentintent=getIntent();

BaseExpandableListAdapteradapter=newBaseExpandableListAdapter()

//提取数据

Bundlebundle=intent.getExtras();

Studentmem_data=(Student)getIntent().getExtras().get("

String[]people=(String[])bundle.getSerializable("

String[][]data=mem_data.info;

publicObjectgetChild(intgroupPosition,intchildPosition)

{

returndata[groupPosition][childPosition];

publiclonggetChildId(intgroupPosition,intchildPosition)

returnchildPosition;

publicintgetChildrenCount(intgroupPosition)

returndata[groupPosition].length;

//设定每个子选项每行的显示方式

privateTextViewgetTextView()

AbsListView.LayoutParamslp=newAbsListView.LayoutParams(

;

TextViewtextView=newTextView(SearchResult.this);

textView.setLayoutParams(lp);

textView.setGravity(Gravity.CENTER_VERTICAL|Gravity.LEFT);

textView.setPadding(36,0,0,0);

textView.setTextSize(20);

returntextView;

//设定每个子选项显示内容

publicViewgetChildView(intgroupPosition,intchildPosition,booleanisLastChild,ViewconvertView,ViewGroupParent)

TextViewtextView=getTextView();

textView.setText("

"

+getChild(groupPosition,childPosition).toString());

publicObjectgetGroup(intgroupPosition)

returnpeople[groupPosition];

publicintgetGroupCount()

returnpeople.length;

publiclonggetGroupId(intgroupPosition)

returngroupPosition;

//设定每个组选项显示内容

publicViewgetGroupView(intgroupPosition,booleanisExpanded,ViewconvertView,ViewGroupparnet)

LinearLayoutll=newLinearLayout(SearchResult.this);

ll.setOrientation(0);

+getGroup(groupPosition).toString());

ll.addView(textView);

returnll;

};

ExpandableListViewexpandListView=(ExpandableListView)findViewById(;

expandListView.setAdapter(adapter);

3.增添数据界面:

根据文本框输入内容进行数据的插入,且具有完整性和重复性的判断,插入成功失败均会产生提示

publicclassAddextendsActivity{

Buttonbtn_Accept;

Buttonbtn_Cancle;

TextViewET_name;

TextViewET_NO;

TextViewET_Pro;

TextViewET_Age;

RadioGrouprg;

Stringradio_sex="

男"

;

db=SQLiteDatabase.openDatabase(this.getFilesDir().toString()+"

null,SQLiteDatabase.OPEN_READWRITE);

btn_Accept=(Button)findViewById(;

btn_Cancle=(Button)findViewById(;

ET_name=(TextView)findViewById(;

ET_NO=(TextView)findViewById(;

ET_Pro=(TextView)findViewById(;

ET_Age=(TextView)findViewById(;

rg=(RadioGroup)findViewById(;

rg.setOnCheckedChangeListener(newOnCheckedChangeListener(){

publicvoidonCheckedChanged(RadioGroupgroup,intCheckedId){

radio_sex=CheckedId==?

:

女"

//提交操作

btn_Accept.setOnClickListener(newOnClickListener()

{

Stringname=ET_name.getText().toString();

StringNO=ET_NO.getText().toString();

Stringsex=radio_sex;

Stringpro=ET_Pro.getText().toString();

Stringage=ET_Age.getText().toString();

//规范性与完整性判断

try

{

//插入数据

db.execSQL("

insertintostudentvalues(?

?

newString[]{name,NO,sex,pro,age});

catch(SQLiteExceptione)

Toast.makeText(Add.this,"

插入数据失败,请检查数据规范性与学号的唯一性"

return;

Toast.makeText(Add.this,"

成功插入一条数据:

+"

\n"

+name+"

+NO+"

+sex+"

+pro+"

+age,Toast.LENGTH_SHORT).show();

btn_Cancle.setOnClickListener(newOnClickListener()

4.修改数据界面:

查找界面:

对文本框内输入的数据进行精确查找,成功后转入修改界面

修改界面:

文本框内默认显示之前的数据,修改完成点击确定以文本框内的信息对数据进行更新

查找:

btn_Accept.setOnClickListener(newOnClickListener()

Stringname=ET_Modify_Name.getText().toString();

StringNO=ET_Modify_No.getText().toString();

select*fromstudentwhere"

+"

name=?

andNO=?

newString[]{name,NO});

//判断查找结果是否为空

Toast.makeText(Modify.this,"

记录不存在"

Stringmem_name=null;

Stringmem_No=null;

Stringmem_profession=null;

Stringmem_sex=null;

Stringmem_age=null;

//保存所有数据

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

当前位置:首页 > 自然科学 > 生物学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1