ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:24.29KB ,
资源ID:16522430      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/16522430.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Android学生信息管理系统APP文档格式.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

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

1、4、具体实现1.主界面:主界面显示所有功能,每个按钮点击后,跳转进入相应功能核心代码:public class Main extends Activity SQLiteDatabase db; Button btn_search; Button btn_modify; Button btn_add; Button btn_delete; Button btn_quit; Button btn_show; Override protected void onCreate(Bundle savedInstanceState) requestWindowFeature(Window.FEATURE_

2、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) findViewBy

3、Id(; btn_delete = (Button) findViewById(; btn_quit = (Button) findViewById(; btn_show = (Button) findViewById(; try Cursor cursor = db.rawQuery(select * from student cursor.close(); catch(SQLiteException e) db.execSQL(create table student + ( name TEXT, NO TEXT Primary Key, sex TEXT, profession TEXT

4、, age TEXT); /显示所有数据按钮的功能实现 btn_show.setOnClickListener(new OnClickListener() public void onClick(View source) /获取指针 Cursor cursor = db.rawQuery( /判断数据库是否不存在任何数据 if(cursor.moveToFirst() = false) Toast.makeText(Main.this, 不存在记录, Toast.LENGTH_SHORT).show(); else List p = new ArrayList re_name = new Ar

5、rayList info = new ArrayList /保存搜索出的所有数据 for(cursor.moveToFirst() ; !cursor.isAfterLast() ; cursor.moveToNext() int nameColume = cursor.getColumnIndex(name int NOColume = cursor.getColumnIndex(NO int proColume = cursor.getColumnIndex(profession int sexColume = cursor.getColumnIndex(sex int ageColume

6、 = cursor.getColumnIndex(age Student student = new Student(); student.name = 姓名:+cursor.getString(nameColume); student.NO = 学号:+cursor.getString(NOColume); student.sex = 性别:+cursor.getString(sexColume); student.profession = 专业:+cursor.getString(proColume); student.age = 年龄:+cursor.getString(ageColum

7、e); p.add(student); String temp = student.MakeString(); info.add(temp); String newname = cursor.getString(nameColume); re_name.add(newname); /对保存的数据进行封装 String Cur_name = new Stringre_name.size(); Cur_name = re_name.toArray(Cur_name); String Cur_info = new Stringinfo.size(); Cur_info = info.toArray(

8、Cur_info); Bundle bundle = new Bundle(); bundle.putStringArray(, Cur_name); Student data = new Student(); data.info = Cur_info; /将封装的数据传递给结果界面的activity Intent intent = new Intent(Main.this,SearchResult.class); intent.putExtras(bundle); intent.putExtra(data, data); startActivity(intent); cursor.close

9、(); );/为剩下的按钮绑定监听器实现跳转功能 btn_search.setOnClickListener(new OnClickListener() Intent intent = new Intent(Main.this,Search.class); startActivity(intent); btn_modify.setOnClickListener(new OnClickListener() Intent intent = new Intent(Main.this,Modify.class); btn_add.setOnClickListener(new OnClickListen

10、er() Intent intent = new Intent(Main.this,Add.class); btn_delete.setOnClickListener(new OnClickListener() Intent intent = new Intent(Main.this,Delete.class); btn_quit.setOnClickListener(new OnClickListener() db.close(); finish(); 2.数据显示界面:按姓名排列,点击条目展开具体信息public class SearchResult extends Activity Su

11、ppressLint(RtlHardcoded public void onCreate(Bundle savedInstanceState) /获取传送来的数据 final Intent intent = getIntent(); BaseExpandableListAdapter adapter = new BaseExpandableListAdapter()/提取数据 Bundle bundle = intent.getExtras(); Student mem_data = (Student) getIntent().getExtras().get( String people =

12、(String) bundle.getSerializable( String data = mem_data.info; public Object getChild(int groupPosition,int childPosition) return datagroupPositionchildPosition; public long getChildId(int groupPosition,int childPosition) return childPosition; public int getChildrenCount(int groupPosition) return dat

13、agroupPosition.length; /设定每个子选项每行的显示方式 private TextView getTextView() AbsListView.LayoutParams lp = new AbsListView.LayoutParams( , ; TextView textView = new TextView(SearchResult.this); textView.setLayoutParams(lp); textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); textView.setPadding(36

14、, 0, 0, 0); textView.setTextSize(20); return textView; /设定每个子选项显示内容 public View getChildView(int groupPosition , int childPosition,boolean isLastChild,View convertView,ViewGroup Parent) TextView textView = getTextView(); textView.setText( +getChild(groupPosition,childPosition).toString(); public Obj

15、ect getGroup(int groupPosition) return peoplegroupPosition; public int getGroupCount() return people.length; public long getGroupId(int groupPosition) return groupPosition; /设定每个组选项显示内容 public View getGroupView(int groupPosition, boolean isExpanded ,View convertView , ViewGroup parnet) LinearLayout

16、ll = new LinearLayout(SearchResult.this); ll.setOrientation(0);+getGroup(groupPosition).toString(); ll.addView(textView); return ll; ; ExpandableListView expandListView = (ExpandableListView) findViewById(; expandListView.setAdapter(adapter);3.增添数据界面:根据文本框输入内容进行数据的插入,且具有完整性和重复性的判断,插入成功失败均会产生提示public

17、 class Add extends Activity Button btn_Accept; Button btn_Cancle; TextView ET_name; TextView ET_NO; TextView ET_Pro; TextView ET_Age; RadioGroup rg; String radio_sex = 男; db = SQLiteDatabase.openDatabase(this.getFilesDir().toString()+, null,SQLiteDatabase.OPEN_READWRITE); btn_Accept = (Button) findV

18、iewById(; 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(new OnCheckedChangeListener() public void onChecke

19、dChanged(RadioGroup group, int CheckedId) radio_sex = CheckedId = ? :女 /提交操作 btn_Accept.setOnClickListener(new OnClickListener() String name = ET_name.getText().toString(); String NO = ET_NO.getText().toString(); String sex = radio_sex; String pro = ET_Pro.getText().toString(); String age = ET_Age.g

20、etText().toString(); /规范性与完整性判断 try /插入数据 db.execSQL(insert into student values( ?, ?,new String name, NO, sex, pro, age); catch(SQLiteException e) Toast.makeText(Add.this, 插入数据失败,请检查数据规范性与学号的唯一性 return; Toast.makeText(Add.this, 成功插入一条数据:+n+name+NO+sex+pro+age, Toast.LENGTH_SHORT).show(); btn_Cancle

21、.setOnClickListener(new OnClickListener()4.修改数据界面:查找界面:对文本框内输入的数据进行精确查找,成功后转入修改界面修改界面:文本框内默认显示之前的数据,修改完成点击确定以文本框内的信息对数据进行更新查找:btn_Accept.setOnClickListener(new OnClickListener() String name = ET_Modify_Name.getText().toString(); String NO = ET_Modify_No.getText().toString();select * from student where + name=?and NO=? , new String name, NO); /判断查找结果是否为空 Toast.makeText(Modify.this, 记录不存在 String mem_name = null; String mem_No = null; String mem_profession = null; String mem_sex = null; String mem_age = null; /保存所有数据

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

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