发布于 2016-05-11 03:45:47 | 459 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


这篇文章主要介绍了如何简单实现Android学生管理系统,特别适合计算机专业的即将毕业的同学学习借鉴制作学生管理系统,感兴趣的小伙伴们可以参考一下

本文实例讲述了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;
 }
}


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务