Android学生信息治理系统APP.doc





《Android学生信息治理系统APP.doc》由会员分享,可在线阅读,更多相关《Android学生信息治理系统APP.doc(28页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-_AndroidAndroid 学生信息管理系统学生信息管理系统 APPAPP1、需求分析为了方便的进行对学生数据库的操作,本 app 可在 android 设备上进行对学生信息数据库的信息管理功能,具体功能如下:1.对数据库中所有学生姓名进行显示,对各个条目进行点击可展开具体信息2.查询数据:查询数据是根据姓名与学号两个条件进行查询,两者满足任一条件则进行模糊查询,两个条件同时满足则进行精确查询,查询结果界面与功能一中相同,以姓名排列,点击展开所有信息3.增加数据:在数据库中增添条目,包括姓名(字符串),学号(数字,主键),性别(单选框),年龄(数字),专业(字符串)。每个条目均有误输入设
2、定,且主键可检查重复性,所有数据可检查完整性,若插入成功则会显示一条消息提示成功,若失败则会提示检查主键重复或者数据不完整4.修改数据:根据姓名学号进行精确查找,查找成功后转入修改界面,为了防止漏填与便捷修改界面会默认填充之前的数据(除学号),修改完毕即可更新,同样会检查数据完整性-_5.删除数据:根据姓名学号进行精确查找,查找成功则会进行删除,并显示一条删除成功的提示,若失败,也会进行提示2、概念结构设计ER 图:3、逻辑结构设计学生:姓名(字符串)学号(数字,主码)-_性别(单选框)年龄(数字)专业(字符串)create table student(name TEXT,NO TEXT Pr
3、imary Key,sex TEXT,profession TEXT,age TEXT)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;Overrideprotected void onCreate(Bundle savedInstanceState
4、) requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);super.onCreate(savedInstanceState);setContentView(R.layout.layout_main);/打开数据库,若不存在,则创建 db = SQLiteDatabase.openOrCreateDatabase(this.getFilesD
5、ir().toString()+“/Student.db3“, null);btn_search = (Button) findViewById(R.id.btn_search);btn_modify = (Button) findViewById(R.id.btn_modify);btn_add = (Button) findViewById(R.id.btn_add);btn_delete = (Button) findViewById(R.id.btn_delete);btn_quit = (Button) findViewById(R.id.btn_quit);btn_show = (
6、Button) findViewById(R.id.Btn_show);tryCursor cursor = db.rawQuery(“select * from student“, null);cursor.close();catch(SQLiteException e)-_db.execSQL(“create table student“+ “(“+ “name TEXT,“+ “NO TEXT Primary Key,“+ “sex TEXT,“+ “profession TEXT,“+ “age TEXT“+ “)“);/显示所有数据按钮的功能实现 btn_show.setOnClic
7、kListener(new OnClickListener()public void onClick(View source) /获取指针 Cursor cursor = db.rawQuery(“select * from student“, null);/判断数据库是否不存在任何数据 if(cursor.moveToFirst() = false)Toast.makeText(Main.this, “不存在记录“, Toast.LENGTH_SHORT).show();elseList p = new ArrayList();List re_name = new ArrayList();L
8、ist 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
9、ageColume = 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 = “年龄:“+curs
10、or.getString(ageColume);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 = i
11、nfo.toArray(Cur_info);Bundle bundle = new Bundle();bundle.putStringArray(“name“, 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);
12、cursor.close(););/为剩下的按钮绑定监听器实现跳转功能 btn_search.setOnClickListener(new OnClickListener()public void onClick(View source) Intent intent = new Intent(Main.this,Search.class);startActivity(intent);-_);btn_modify.setOnClickListener(new OnClickListener()public void onClick(View source) Intent intent = new
13、 Intent(Main.this,Modify.class);startActivity(intent););btn_add.setOnClickListener(new OnClickListener()public void onClick(View source) Intent intent = new Intent(Main.this,Add.class);startActivity(intent););btn_delete.setOnClickListener(new OnClickListener()public void onClick(View source) Intent
14、intent = new Intent(Main.this,Delete.class);startActivity(intent););btn_quit.setOnClickListener(new OnClickListener()public void onClick(View source) db.close();finish(););-_2.数据显示界面:按姓名排列,点击条目展开具体信息核心代码:public class SearchResult extends ActivitySuppressLint(“RtlHardcoded“)public void onCreate(Bundl
15、e savedInstanceState)requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);/获取传送来的数据 super.onCreate(savedInstanceState);setContentView(R.layout.layout_result);final Intent intent = getIntent();-_Base
16、ExpandableListAdapter adapter = new BaseExpandableListAdapter()/提取数据 Bundle bundle = intent.getExtras();Student mem_data = (Student) getIntent().getExtras().get(“data“);String people = (String) bundle.getSerializable(“name“);String data = mem_data.info;public Object getChild(int groupPosition,int ch
17、ildPosition)return datagroupPositionchildPosition;public long getChildId(int groupPosition,int childPosition)return childPosition;public int getChildrenCount(int groupPosition)return datagroupPosition.length;/设定每个子选项每行的显示方式 private TextView getTextView()AbsListView.LayoutParams lp = new AbsListView.
18、LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);TextView textView = new TextView(SearchResult.this);textView.setLayoutParams(lp);textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);textView.setPadding(36, 0, 0, 0);textView.setTextSize(20);return textVie
19、w;/设定每个子选项显示内容 public View getChildView(int groupPosition , int childPosition,boolean isLastChild,View convertView,ViewGroup Parent)-_TextView textView = getTextView();textView.setText(“ “+getChild(groupPosition,childPosition).toString();return textView;public Object getGroup(int groupPosition)retur
20、n 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 ll = new LinearLayout(SearchResult.this);ll
21、.setOrientation(0);TextView textView = getTextView();textView.setText(“ “+getGroup(groupPosition).toString();ll.addView(textView);return ll;ExpandableListView expandListView = (ExpandableListView) findViewById(R.id.list);expandListView.setAdapter(adapter);-_3.增添数据界面:根据文本框输入内容进行数据的插入,且具有完整性和重复性的判断,插入
22、成功失败均会产生提示核心代码:public class Add extends Activity SQLiteDatabase db;Button btn_Accept;Button btn_Cancle;TextView ET_name;-_TextView ET_NO;TextView ET_Pro;TextView ET_Age;RadioGroup rg;String radio_sex = “男“;Overrideprotected void onCreate(Bundle savedInstanceState) requestWindowFeature(Window.FEATURE
23、_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);super.onCreate(savedInstanceState);setContentView(R.layout.layout_add);db = SQLiteDatabase.openDatabase(this.getFilesDir().toString()+“/Student.db3“, null,SQLiteDatabase.OPEN_READW
24、RITE);btn_Accept = (Button) findViewById(R.id.btn_Accept);btn_Cancle = (Button) findViewById(R.id.btn_Cancle);ET_name = (TextView) findViewById(R.id.ET_Add_name);ET_NO = (TextView) findViewById(R.id.ET_Add_NO);ET_Pro = (TextView) findViewById(R.id.ET_Add_Pro);ET_Age = (TextView) findViewById(R.id.ET
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Android 学生 信息 治理 系统 APP

限制150内