簡單實(shí)現(xiàn)Android學(xué)生管理系統(tǒng)(附源碼)
本文實(shí)例講述了Android實(shí)現(xiàn)學(xué)生管理系統(tǒng),分享給大家供大家參考。具體如下:
(1)管理系統(tǒng)實(shí)現(xiàn)的功能主要是:學(xué)生、教師的注冊(cè)登錄,和選課,以及修改學(xué)生的成績等基本簡單的功能,最主要的是實(shí)現(xiàn)一些Dialog的使用。
界面如下:




(2)主要代碼如下:(個(gè)人留作筆記,如需要完整代碼,在最下邊免費(fèi)下載)
下邊是一個(gè)適配器,適配器是為了一個(gè)listvie進(jìn)行設(shè)置值,其中加載的是一個(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);
// 獲得某一個(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;
}
}
源碼下載: Android學(xué)生管理系統(tǒng)
希望本文所述對(duì)大家學(xué)習(xí)Android軟件編程有所幫助。
相關(guān)文章
Android實(shí)現(xiàn)簡單的自定義ViewGroup流式布局
本文我們將一起復(fù)習(xí)一下ViewGroup的測(cè)量布局方式。然后會(huì)以入門級(jí)的 FlowLayout 為例,來看看流式布局是如何測(cè)量與布局的,感興趣的可以了解一下2022-12-12
Android內(nèi)嵌Unity并實(shí)現(xiàn)互相跳轉(zhuǎn)的實(shí)例代碼
這篇文章主要介紹了Android內(nèi)嵌Unity并實(shí)現(xiàn)互相跳轉(zhuǎn)的實(shí)例代碼,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11
Mac中Eclipse連不上Android手機(jī)的解決方法
這篇文章主要介紹了Mac中Eclipse連不上Android手機(jī)的解決方法,本文方法同樣適用其它的移動(dòng)設(shè)備,需要的朋友可以參考下2015-06-06
Android實(shí)現(xiàn)藍(lán)牙聊天功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)藍(lán)牙聊天功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06
android開發(fā)環(huán)境中SDK文件夾下的所需內(nèi)容詳解
在本篇文章里小編給大家整理的是關(guān)于android開發(fā)環(huán)境中SDK文件夾下的所需內(nèi)容詳解,有興趣的朋友們參考學(xué)習(xí)下。2019-09-09
Android中編寫屬性動(dòng)畫PropertyAnimation的進(jìn)階實(shí)例
這篇文章主要介紹了Android中編寫屬性動(dòng)畫PropertyAnimation的進(jìn)階實(shí)例,包括一些縮放和淡入淡出效果的設(shè)計(jì),強(qiáng)大且不算復(fù)雜,需要的朋友可以參考下2016-04-04
android 9.0 launcher3 去掉抽屜式顯示所有 app(代碼詳解)
本文通過實(shí)例代碼給大家介紹了android 9.0 Launcher3 去掉抽屜式,顯示所有 app,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11

