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




(2)主要代碼如下:(個人留作筆記,如需要完整代碼,在最下邊免費下載)
下邊是一個適配器,適配器是為了一個listvie進行設(shè)置值,其中加載的是一個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更新數(shù)據(jù)
*/
@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的反射機制,結(jié)合工廠模式進行操作:
public class PersonFactory {
/**
* 根據(jù)類的名稱來生產(chǎn)對象: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;
}
/**
* 根據(jù)類型來創(chuàng)建對象
*/
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)對象: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)
希望本文所述對大家學(xué)習(xí)Android軟件編程有所幫助。
相關(guān)文章
Android圖片翻轉(zhuǎn)動畫簡易實現(xiàn)代碼
Android圖片翻轉(zhuǎn)動畫效果如何實現(xiàn),本文將給你一個驚喜,實現(xiàn)代碼已經(jīng)列出,需要的朋友可以參考下2012-11-11
Android實現(xiàn)網(wǎng)易新聞客戶端側(cè)滑菜單(1)
這篇文章主要為大家詳細介紹了Android實現(xiàn)網(wǎng)易新聞客戶端側(cè)滑菜單第一篇,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11
Android實現(xiàn)讀寫USB串口數(shù)據(jù)
這篇文章主要為大家詳細介紹了Android實現(xiàn)讀寫USB串口數(shù)據(jù),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-09-09
詳解如何使用VisualStudio高效開發(fā)調(diào)試AndroidNDK
這篇文章主要介紹了詳解如何使用VisualStudio高效開發(fā)調(diào)試AndroidNDK,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12
android RecyclerView添加footerview詳解
大家好,本篇文章主要講的是android RecyclerView添加footerview詳解,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下2022-01-01
Flutter插件開發(fā)之HmsScanKit實現(xiàn)示例詳解
這篇文章主要為大家介紹了Flutter插件開發(fā)之HmsScanKit實現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11

