簡單實現Android學生管理系統(附源碼)_Android

來源:互聯網
上載者:User

本文執行個體講述了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軟體編程有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.