(1)管理系統(tǒng)實(shí)現(xiàn)的功能主要是:學(xué)生、教師的注冊(cè)登錄,和選課,和修改學(xué)生的成績(jī)等基本簡(jiǎn)單的功能,最主要的是實(shí)現(xiàn)1些Dialog的使用。
界面以下:
(2)主要代碼以下:(個(gè)人留作筆記,如需要完全代碼,在最下邊免費(fèi)下載)
下邊是1個(gè)適配器,適配器是為了1個(gè)listvie進(jìn)行設(shè)置值,其中加載的是1個(gè)itemview,適配器中還是用了繼承的方法,用于通知適配器進(jìn)行更新。
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更新數(shù)據(jù)
*/
@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
}
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
//這里加載的每個(gè)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);
// 取得某1個(gè)位置的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的反射機(jī)制,結(jié)合工廠模式進(jìn)行操作:
public class PersonFactory {
/**
* 根據(jù)類的名稱來生產(chǎn)對(duì)象:java的反射機(jī)制使用
*
* @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;
}
/**
* 根據(jù)類型來創(chuàng)建對(duì)象
*/
public PersonInter getHair(String key) {
if ("student".equals(key)) {
return new StudentImpl();
} else if ("teacher".equals(key)) {
return new TeacherImpl();
}
return null;
}
/**
* 根據(jù)類的名稱來生產(chǎn)對(duì)象: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;
}
}
項(xiàng)目源碼下載地址:http://yunpan.cn/cVHSjNCeRxZqV 訪問密碼 96dd