栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 移动开发 > Android

简单实现Android学生管理系统(附源码)

Android 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

简单实现Android学生管理系统(附源码)

本文实例讲述了Android实现学生管理系统,分享给大家供大家参考。具体如下:

(1)管理系统实现的功能主要是:学生、教师的注册登录,和选课,以及修改学生的成绩等基本简单的功能,最主要的是实现一些Dialog的使用。
界面如下:

(2)主要代码如下:(个人留作笔记,如需要完整代码,在最下边免费下载)

下边是一个适配器,适配器是为了一个listvie进行设置值,其中加载的是一个itemview,适配器中还是用了继承的方法,用于通知适配器进行更新。

public class CourseAdapter extends baseAdapter {

 private Context context;
 private List coursetList;

 public CourseAdapter(Context context, List coursetList) {
 this.context = context;
 this.coursetList = coursetList;
 }

 public int getCount() {
 return coursetList.size();
 }

 public Object getItem(int position) {
 return coursetList.get(position);
 }

 public long getItemId(int position) {
 return position;
 }

 
 @Override
 public void notifyDataSetChanged() {
 super.notifyDataSetChanged();
 }

 public View getView(int position, View convertView, ViewGroup parent) {

 if (convertView == null) {
 //这里加载的每一个item条目的布局文件
 convertView = LayoutInflater.from(context).inflate(
 R.layout.student_score_item, null);
 }

 TextView tv_name = (TextView) convertView.findViewById(R.id.tv_name);
 TextView tv_course = (TextView) convertView
 .findViewById(R.id.tv_course);
 TextView tv_score = (TextView) convertView.findViewById(R.id.tv_score);

 // 获得某一个位置的student
 Course course = coursetList.get(position);
 tv_name.setText(course.getStudentName() + "");
 tv_course.setText(course.getCourseName() + "");
 tv_score.setText(course.getCourseSocre() + "");

 return convertView;
 }

}

(3)还用到了Java的反射机制,结合工厂模式进行操作:

public class PersonFactory {

 
 public PersonInter getPersonByClass(String className) {

 try {
 PersonInter personInter = (PersonInter) Class.forName(className).newInstance();
 return personInter;
 } catch (InstantiationException e) {
 e.printStackTrace();
 } catch (IllegalAccessException e) {
 e.printStackTrace();
 } catch (ClassNotFoundException e) {
 e.printStackTrace();
 }
 return null;
 }

 
 public PersonInter getHair(String key) {
 if ("student".equals(key)) {
 return new StudentImpl();
 } else if ("teacher".equals(key)) {
 return new TeacherImpl();
 }
 return null;
 }

 
 public PersonInter getPersonByClassKey(String key) {

 try {
 Map map = new PropertiesReader().getProperties();

 PersonInter person = (PersonInter) Class.forName(map.get(key)).newInstance();
 return person;
 } catch (InstantiationException e) {
 e.printStackTrace();
 } catch (IllegalAccessException e) {
 e.printStackTrace();
 } catch (ClassNotFoundException e) {
 e.printStackTrace();
 }
 return null;
 }
}

源码下载: Android学生管理系统

希望本文所述对大家学习Android软件编程有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/163876.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号