简单实现Android学生管理系统(附源码)
作者:徐刘根 时间:2022-06-12 05:59:04
本文实例讲述了Android实现学生管理系统,分享给大家供大家参考。具体如下:
(1)管理系统实现的功能主要是:学生、教师的注册登录,和选课,以及修改学生的成绩等基本简单的功能,最主要的是实现一些Dialog的使用。
界面如下:
(2)主要代码如下:(个人留作笔记,如需要完整代码,在最下边免费下载)
下边是一个适配器,适配器是为了一个listvie进行设置值,其中加载的是一个itemview,适配器中还是用了继承的方法,用于通知适配器进行更新。
public class CourseAdapter extends BaseAdapter {
private Context context;
private List<Course> coursetList;
public CourseAdapter(Context context, List<Course> 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;
}
/**
* 通知adapter更新数据
*/
@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 {
/**
* 根据类的名称来生产对象:java的反射机制使用
*
* @param className
* @return
*/
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;
}
/**
* 根据类的名称来生产对象:java的映射
*/
public PersonInter getPersonByClassKey(String key) {
try {
Map<String, String> 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软件编程有所帮助。
标签:Android,管理系统
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#事件实例详解
2022-04-23 22:24:47
Android xUtils更新到3.0后的基本使用规则详解
2023-02-07 23:14:39
![](https://img.aspxhome.com/file/2023/0/123230_0s.png)
Java 迪杰斯特拉算法实现查找最短距离的实现
2022-05-23 01:47:43
![](https://img.aspxhome.com/file/2023/6/86706_0s.png)
深入探讨linux下进程的最大线程数、进程最大数、进程打开的文件数
2021-07-06 00:49:15
C语言经典指针笔试题详解
2021-10-23 12:56:39
![](https://img.aspxhome.com/file/2023/3/127493_0s.png)
基于C#实现简单的随机抽奖小程序
2023-07-14 10:15:50
Spring配置shiro时自定义Realm中属性无法使用注解注入的解决办法
2022-09-18 11:18:22
![](https://img.aspxhome.com/file/2023/2/83122_0s.jpg)
SpringBoot读取yaml文件操作详解
2022-09-16 09:38:31
Java 实现协程的方法
2022-02-18 22:55:05
Maven工程打包jar的多种方式
2022-12-15 06:54:46
![](https://img.aspxhome.com/file/2023/6/67686_0s.png)
C# listview 点击列头排序的实例
2023-11-26 20:09:05
浅谈C#中的委托、事件与异步
2022-04-25 23:05:34
c# 将Datatable数据导出到Excel表格中
2023-12-26 02:03:53
jtds1.1连接sqlserver2000测试示例
2021-06-13 04:57:28
C语言中数据是如何存储在内存中的
2021-07-03 02:13:34
![](https://img.aspxhome.com/file/2023/4/127494_0s.png)
Thymeleaf 3.0 自定义标签方言属性的实例讲解
2023-03-24 20:40:23
Unity实现文本转贴图
2022-05-10 19:53:04
![](https://img.aspxhome.com/file/2023/7/100237_0s.jpg)
Java并发之串行线程池实例解析
2023-01-07 18:35:54
Spring Boot缓存实战 Caffeine示例
2021-11-15 17:39:34
java代码实现MD5加密及验证过程详解
2023-09-26 02:50:45