安卓APP源碼和報(bào)告——學(xué)生信息管理系統(tǒng)
詳情介紹
《移動(dòng)開(kāi)發(fā)技術(shù)II》實(shí)踐考核方案
適用網(wǎng)絡(luò)工程(網(wǎng)絡(luò)軟件開(kāi)發(fā))2018級(jí)
一、考核內(nèi)容:
環(huán)境配置及移動(dòng)開(kāi)發(fā)生命周期、控件的使用、用戶界面設(shè)計(jì)、數(shù)據(jù)存儲(chǔ)與訪問(wèn)、廣播、服務(wù)、網(wǎng)絡(luò)編程、藍(lán)牙應(yīng)用等知識(shí)點(diǎn)。
二、考核方式:
1、通過(guò)提交一個(gè)綜合的項(xiàng)目,學(xué)會(huì)運(yùn)用所學(xué)知識(shí)解決實(shí)際問(wèn)題。
2、項(xiàng)目題目: XX管理系統(tǒng)APP,購(gòu)物商城APP等,也可自命題。
三、考核目的:
1、掌握移動(dòng)開(kāi)發(fā)的生命周期
2、掌握用戶界面以及自定義界面的使用
3、掌握數(shù)據(jù)庫(kù)的應(yīng)用
4、掌握移動(dòng)開(kāi)發(fā)中網(wǎng)絡(luò)程序設(shè)計(jì)
5、掌握移動(dòng)開(kāi)發(fā)的程序設(shè)計(jì)方法。
四、考核要求:
1、完成項(xiàng)目程序設(shè)計(jì);
2、提交的項(xiàng)目運(yùn)行正常,界面友好,功能完善,異常處理較好;
3、項(xiàng)目中功能符合要求,數(shù)據(jù)庫(kù)設(shè)計(jì)合理;
4、文檔資料完善。
五、成績(jī)?cè)u(píng)定:
1、記分制:百分制
2、評(píng)分標(biāo)準(zhǔn):
序號(hào)資料類型分值評(píng)分標(biāo)準(zhǔn)備注1項(xiàng)目描述文檔20需求分析10分?jǐn)?shù)據(jù)庫(kù)設(shè)計(jì)10分2源程序代碼60完整的源代碼30分基本功能具備10分界面友好5分無(wú)明顯的異常10分添加適當(dāng)?shù)淖⑨?分3項(xiàng)目的復(fù)雜性10根據(jù)每位學(xué)生的選題判斷其技術(shù)難度4界面的設(shè)計(jì)10滿足APP界面設(shè)計(jì)要求,界面友好,便于操作
3、項(xiàng)目提交要求:
(1)項(xiàng)目的源程序文件,添加適當(dāng)?shù)淖⑨?,格式合理?/p>
(2)項(xiàng)目描述文檔,包括項(xiàng)目名稱,需求分析,項(xiàng)目功能描述及各個(gè)文件功能描述;
(3)項(xiàng)目運(yùn)行的每個(gè)頁(yè)面截圖到項(xiàng)目文檔中并加以說(shuō)明;
(4)設(shè)計(jì)的APP程序應(yīng)包含登錄頁(yè)面、數(shù)據(jù)顯示頁(yè)面、自定義功能頁(yè)面、查詢頁(yè)面、網(wǎng)絡(luò)狀態(tài)連接頁(yè)面等,其中數(shù)據(jù)存儲(chǔ)需要使用Sqlite數(shù)據(jù)庫(kù),登錄頁(yè)面可以使用SharedPerference或者數(shù)據(jù)庫(kù),并且各個(gè)頁(yè)面需要布局合理;
(5)提交的源程序、項(xiàng)目描述文檔一起打包后,命名:學(xué)號(hào) + 姓名,如181413210張三。
六、考核時(shí)間
1、以學(xué)院安排為準(zhǔn)。
七、其它說(shuō)明:
學(xué)生在多個(gè)項(xiàng)目中選擇一個(gè)完成,或者自選項(xiàng)目。通過(guò)APP項(xiàng)目的設(shè)計(jì)和提交,使學(xué)生能夠逐漸熟悉移動(dòng)開(kāi)發(fā)項(xiàng)目的整個(gè)流程,為今后的進(jìn)一步學(xué)習(xí)打下堅(jiān)實(shí)的基礎(chǔ)
考核教師簽名:
學(xué)生信息管理的設(shè)計(jì)與實(shí)現(xiàn)
一、項(xiàng)目名稱:學(xué)生信息管理的設(shè)計(jì)與實(shí)現(xiàn)
二、項(xiàng)目完成人:
三、項(xiàng)目需求分析:
學(xué)生信息的管理對(duì)于學(xué)校的管理者來(lái)說(shuō)至關(guān)重要,學(xué)生信息是高等學(xué)校非常重要的一項(xiàng)數(shù)據(jù)資源,是一個(gè)教育單位不可缺少一部分。特別是近幾年來(lái),國(guó)家政策的調(diào)整,我國(guó)高等院校大規(guī)模的擴(kuò)招,給高等院校的教學(xué)管理、學(xué)生管理、后勤管理等方面都帶來(lái)不少的沖擊。其包含的數(shù)據(jù)量大,涉及的人員面廣,而且需要及時(shí)更新,故較為復(fù)雜,難以單純地依靠人工管理,而且傳統(tǒng)的人工管理方式既不易于規(guī)范化,管理效率也不高,系統(tǒng)針對(duì)學(xué)校學(xué)生信息的特點(diǎn)以及管理中實(shí)際需要而設(shè)計(jì)。優(yōu)點(diǎn)如下:
用戶可以登錄注冊(cè)
詳細(xì)記錄每位學(xué)生信息,并且可以做出統(tǒng)計(jì)
系統(tǒng)操作人性化、簡(jiǎn)單易用
保證軟件的安全性
界面流暢
四、運(yùn)行環(huán)境
操作系統(tǒng):android
數(shù)據(jù)庫(kù):Sqlite
五、系統(tǒng)功能模塊
(1)注冊(cè)、登錄頁(yè)面 (2)頁(yè)面
admin 666
學(xué)生信息錄入界面 (4) 信息錄入成功界面
(5)學(xué)生信息瀏覽界面 (6)修改學(xué)生信息成功界面
(7)查詢學(xué)生信息界面 (8)學(xué)生信息刪除界面
(9)學(xué)生信息退出界面
核心代碼如下:
AddStudentsActivity類:
public class?AddStudentsActivity?extends?AppCompatActivity?implements?View.OnClickListener {
private?ImageButton?BtnBack;//返回按鈕
private?TextView?tv_title;//頭標(biāo)題
private?EditText?EtName,?EtNumber,?EtYear,?EtSex,?EtBirth,?EtAddress,?EtPhone;
//姓名、學(xué)號(hào)、年齡、性別、出生年月、地址、電話
private?Button?BtnSave;//保存按鈕
DbStudents?dbStudents;//數(shù)據(jù)庫(kù)
List<StudentsBean>?mData;//數(shù)據(jù)源
String?number;//學(xué)號(hào)
@Override
protected void?onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_students);
tv_title=findViewById(R.id.tv_title);//綁定控件
BtnBack?= findViewById(R.id.btn_back);
BtnSave?= findViewById(R.id.btn_save);
BtnBack.setOnClickListener(this);
BtnSave.setOnClickListener(this);
EtNumber?= findViewById(R.id.add_et_number);
EtName?= findViewById(R.id.add_et_name);
EtYear?= findViewById(R.id.add_et_year);
EtSex?= findViewById(R.id.add_et_sex);
EtBirth?= findViewById(R.id.add_et_birthday);
EtAddress?= findViewById(R.id.add_et_address);
EtPhone?= findViewById(R.id.add_et_phone);
dbStudents=?new?DbStudents(this);
mData?=?new?ArrayList<>();
initData();
}
/**
* 保存修改的信息
* */
private void?initData() {
Intent intent = getIntent();
if?(intent !=?null) {
number?= intent.getStringExtra(“number”);
if?(number?!=?null) {
tv_title.setText(“修改學(xué)生信息”);
BtnSave.setText(“修 改”);
EtNumber.setText(intent.getStringExtra(“number”));
EtName.setText(intent.getStringExtra(“name”));
EtYear.setText(intent.getStringExtra(“year”));
EtSex.setText(intent.getStringExtra(“sex”));
EtBirth.setText(intent.getStringExtra(“birth”));
EtAddress.setText(intent.getStringExtra(“address”));
EtPhone.setText(intent.getStringExtra(“phone”));
}
}
}
@Override
public void?onClick(View v) {
switch?(v.getId()) {
case?R.id.btn_back:
Intent intent1 =?new?Intent(AddStudentsActivity.this, MainActivity.class);
startActivity(intent1);
break;
case?R.id.btn_save:
//輸入
String number =?EtNumber.getText().toString().trim();
String name =?EtName.getText().toString().trim();
String year =?EtYear.getText().toString().trim();
String sex =?EtSex.getText().toString().trim();
String birth =?EtBirth.getText().toString().trim();
String address =?EtAddress.getText().toString().trim();
String phone =?EtPhone.getText().toString().trim();
StudentsBean studentsBeans =?dbStudents.QueryFromStudentByNumber(number);
if?(number !=?null) {//修改操作
if?(name.length() > 0) {
if?(dbStudents.updateStudent(number, name, year,sex,birth,address,phone)) {
Toast.makeText(AddStudentsActivity.this,“修改成功”,Toast.LENGTH_LONG).show();
setResult(2);
showDeleteDialog2();
}
}?else?{
Toast.makeText(AddStudentsActivity.this,“修改的內(nèi)容不能為空!”,Toast.LENGTH_LONG).show();
}
}
if?(TextUtils.isEmpty(name)) {
Toast.makeText(AddStudentsActivity.this,?“錄入失??!請(qǐng)輸入姓名”, Toast.LENGTH_SHORT).show();
}?else if?(TextUtils.isEmpty(number)) {
Toast.makeText(AddStudentsActivity.this,?“錄入失敗!請(qǐng)輸入學(xué)號(hào)”, Toast.LENGTH_SHORT).show();
}?else if?(TextUtils.isEmpty(year)) {
Toast.makeText(AddStudentsActivity.this,?“錄入失敗!請(qǐng)輸入年齡”, Toast.LENGTH_SHORT).show();
}?else if?(TextUtils.isEmpty(sex)) {
Toast.makeText(AddStudentsActivity.this,?“錄入失敗!請(qǐng)輸入性別”, Toast.LENGTH_SHORT).show();
}?else if?(TextUtils.isEmpty(birth)) {
Toast.makeText(AddStudentsActivity.this,?“錄入失敗!請(qǐng)輸入出生年月”, Toast.LENGTH_SHORT).show();
}?else if?(TextUtils.isEmpty(address)) {
Toast.makeText(AddStudentsActivity.this,?“錄入失??!請(qǐng)輸入地址”, Toast.LENGTH_SHORT).show();
}?else if?(TextUtils.isEmpty(phone)) {
Toast.makeText(AddStudentsActivity.this,?“錄入失??!請(qǐng)輸入電話”, Toast.LENGTH_SHORT).show();
}else if?(studentsBeans !=?null){
Toast.makeText(AddStudentsActivity.this,?“學(xué)號(hào)重復(fù)”, Toast.LENGTH_SHORT).show();
}
else?{
System.out.println(“是否為空: “+dbStudents);
dbStudents.insertStudents(number, name, year, sex, birth, address, phone);
showDeleteDialog();
}
}
}
/**
* 修改提示框
* */
private void?showDeleteDialog2() {
final?AlertDialog.Builder builder =?new?AlertDialog.Builder(this);
builder.setTitle(“修改成功提示”)
.setMessage(“已成功修改!”)
.setPositiveButton(“ok”,?new?DialogInterface.OnClickListener() {
@Override
public void?onClick(DialogInterface dialog,?int?which) {
Intent intent=new?Intent(AddStudentsActivity.this,MainActivity.class);
startActivity(intent);
}
});
builder.create().show();
}
/**
* 保存提示框
* */
private void?showDeleteDialog() {
final?AlertDialog.Builder builder =?new?AlertDialog.Builder(this);
builder.setTitle(“錄入成功提示”)
.setMessage(“已成功錄入!\n是否繼續(xù)?”)
.setPositiveButton(“否”,?new?DialogInterface.OnClickListener() {
@Override
public void?onClick(DialogInterface dialog,?int?which) {
Intent intent=new?Intent(AddStudentsActivity.this,MainActivity.class);
startActivity(intent);
}
})
.setNegativeButton(“是”,?new?DialogInterface.OnClickListener() {
@Override
public void?onClick(DialogInterface dialog,?int?which) {
//將輸入框清空
EtNumber.setText(“”);
EtName.setText(“”);
EtYear.setText(“”);
EtSex.setText(“”);
EtBirth.setText(“”);
EtAddress.setText(“”);
EtPhone.setText(“”);
}
});
builder.create().show();
}
DeleteStudentsActivity類:
public class?DeleteStudentsActivity?extends?AppCompatActivity {
ListView?listView;//列表
List<StudentsBean>?mData;//數(shù)據(jù)源
Adapter_del?adapter;//適配器
DbStudents?dbStudents;//數(shù)據(jù)庫(kù)
@Override
protected void?onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_delete_students);//控件綁定
listView?= findViewById(R.id.del_lv);
dbStudents?=?new?DbStudents(this);
mData?=?new?ArrayList<>();
System.out.println(“長(zhǎng)度為:”?+?mData.size());
//設(shè)置適配器:加載每一行數(shù)據(jù)到列表當(dāng)中
adapter?=?new?Adapter_del(this,?mData);
listView.setAdapter(adapter);
loadData();
setLVClickListener();
}
/**
* listView長(zhǎng)按事件
*/
private void?setLVClickListener() {
listView.setOnItemLongClickListener(new?AdapterView.OnItemLongClickListener() {
@Override
public boolean?onItemLongClick(AdapterView<?> parent, View view,?int?position,?long?id) {
StudentsBean studentsBean =?mData.get(position);
deleteItem(studentsBean);
return false;
}
});
}
/**
* 長(zhǎng)按刪除
* */
private void?deleteItem(final?StudentsBean studentsBean) {
final?String delNumber = studentsBean.getNumber();
AlertDialog.Builder builder =?new?AlertDialog.Builder(this);
builder.setTitle(“提示信息”).setMessage(“您確定要?jiǎng)h除這條記錄么?”)
.setNegativeButton(“取消”,?null)
.setPositiveButton(“確定”,?new?DialogInterface.OnClickListener() {
@Override
public void?onClick(DialogInterface dialog,?int?which) {
DbStudents.deleteItemFromStudentByNumber(delNumber);
mData.remove(studentsBean);?//實(shí)時(shí)刷新,從數(shù)據(jù)源刪除
adapter.notifyDataSetChanged();
}
});
builder.create().show();
}
/**
* 顯示學(xué)生信息列表
* */
private void?loadData() {
List<StudentsBean> list = DbStudents.search();
mData.clear();
mData.addAll(list);
adapter.notifyDataSetChanged();
}
/**
* 按鈕點(diǎn)擊事件
* */
public void?onClick(View v) {
switch?(v.getId()) {
case?R.id.iv_back:
Intent intent =?new?Intent(DeleteStudentsActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
}
}
DataSupper類
public class Users extends DataSupport {
private String name;
private String password;
private String email;
private String addrs;
private int age;
private String sex;
public Users ( String name, String password) {
this.name = name;
this.password = password;
}
public Users ( String name, String password,String email,String addrs,String sex,int age) {
this.name = name;
this.password = password;
this.addrs = addrs;
this.email = email;
this.age = age;
this.sex = sex;
}
public Users () {
}
public String get_name () {
return name;
}
public String get_password () { return password; }
public String get_email() {
return email;
}
public int get_age(){ return age; }
public String get_addrs(){ return addrs; }
public String get_sex() { return sex; }
public void set_name(String name) {
this.name=name;
}
public void setPassword(String password) {
this.password = password;
}
public void setEmail(String email) {
this.email = email;
}
public void setAge(int age) {
this.age = age;
}
public void setAddrs(String addrs) { this.addrs = addrs; }
public void setSex(String sex) { this.sex = sex; }
}
MainActivity類:
public class?MainActivity?extends?AppCompatActivity?implements?View.OnClickListener{
private?Button?btnAdd,btnSearch,btnMod,btnQuery,btnDelete,btnBack;
//按鈕:錄入、瀏覽、修改、查詢、刪除、退出
@Override
protected void?onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);//事件綁定
btnAdd=findViewById(R.id.add_students);
btnSearch=findViewById(R.id.search_students);
btnMod=findViewById(R.id.mod_students);
btnDelete=findViewById(R.id.delete_students);
btnQuery=findViewById(R.id.query_students);
btnBack=findViewById(R.id.btn_back);
btnBack.setOnClickListener(this);
btnQuery.setOnClickListener(this);
btnDelete.setOnClickListener(this);
btnMod.setOnClickListener(this);
btnAdd.setOnClickListener(this);
btnSearch.setOnClickListener(this);
}
/**
* 按鈕點(diǎn)擊事件
* */
@Override
public void?onClick(View v) {
switch?(v.getId()){
case?R.id.add_students:
Intent intent1=new?Intent(MainActivity.this,AddStudentsActivity.class);
startActivity(intent1);
break;
case?R.id.search_students:
Intent intent2=new?Intent(MainActivity.this,SearchStudentsActivity.class);
startActivity(intent2);
break;
case?R.id.mod_students:
Intent intent3=new?Intent(MainActivity.this,ModStudentsActivity.class);
startActivity(intent3);
break;
case?R.id.query_students:
Intent intent4=new?Intent(MainActivity.this,QueryStudentsActivity.class);
startActivity(intent4);
break;
case?R.id.delete_students:
Intent intent5=new?Intent(MainActivity.this,DeleteStudentsActivity.class);
startActivity(intent5);
break;
case?R.id.btn_back:
DigLogShow();
break;
}
}
/**
* 退出提示
* */
private void?DigLogShow() {
final?AlertDialog.Builder builder =?new?AlertDialog.Builder(this);
builder.setTitle(“退出提示”)
.setMessage(“是否退出?”)
.setPositiveButton(“否”,?new?DialogInterface.OnClickListener() {
@Override
public void?onClick(DialogInterface dialog,?int?which) {
}
})
.setNegativeButton(“是”,?new?DialogInterface.OnClickListener() {
@Override
public void?onClick(DialogInterface dialog,?int?which) {
Intent intent6=new?Intent(MainActivity.this,LoginActivity.class);
SharedPreferences sharedPreferences = getSharedPreferences(“zidong”, Context.MODE_PRIVATE);
sharedPreferences.edit().clear().apply();
Toast.makeText(MainActivity.this,“退出成功!”,Toast.LENGTH_LONG).show();
startActivity(intent6);
}
});
builder.create().show();
}
}
ModStudentSActivity類:
public class?ModStudentsActivity?extends?AppCompatActivity?implements?View.OnClickListener {
ListView?UpdateLv;//列表
EditText?EtNumber;//學(xué)號(hào)
List<StudentsBean>?mData;//數(shù)據(jù)源
Adapter_update?adapter;//適配器對(duì)象
DbStudents?dbStudents;//數(shù)據(jù)庫(kù)
@Override
protected void?onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mod_students);//綁定事件
UpdateLv?= findViewById(R.id.update_lv);
EtNumber?= findViewById(R.id.et_update);
mData?=?new?ArrayList<>();
adapter?=?new?Adapter_update(this,?mData);
UpdateLv.setAdapter(adapter);//適配器列表顯示
dbStudents?=?new?DbStudents(this);
}
/**
* 按鈕點(diǎn)擊事件
* */
@Override
public void?onClick(View v) {
switch?(v.getId()) {
case?R.id.iv_back:
Intent intent =?new?Intent(ModStudentsActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
case?R.id.update_iv:
String number =?EtNumber.getText().toString().trim();
StudentsBean studentsBeans =?dbStudents.QueryFromStudentByNumber(number);//查詢學(xué)號(hào)是否存在
if?(TextUtils.isEmpty(number)) {
Toast.makeText(this,?“請(qǐng)輸入學(xué)號(hào)!”, Toast.LENGTH_SHORT).show();
}?else if?(studentsBeans ==?null) {
Toast.makeText(this,?“該學(xué)號(hào)不存在!”, Toast.LENGTH_SHORT).show();
}?else?{
//開(kāi)始搜索
List<StudentsBean> list = DbStudents.getStudentListByNumber(number);//查詢?cè)搶W(xué)號(hào)的所有信息
mData.clear();//將原來(lái)搜索的消息清除
mData.addAll(list);
adapter.notifyDataSetChanged();//實(shí)時(shí)更新
initData();//修改信息函數(shù)
break;
}
}
}
/**
* 修改信息點(diǎn)擊事件,點(diǎn)擊就會(huì)進(jìn)入到修改頁(yè)面進(jìn)行修改
* */
private void?initData() {
dbStudents=?new?DbStudents(this);?//創(chuàng)建數(shù)據(jù)庫(kù)
UpdateLv.setOnItemClickListener(new?AdapterView.OnItemClickListener() {
@Override
public void?onItemClick(AdapterView<?> parent, View view,?int?position,?long?id){
StudentsBean studentsBean =?mData.get(position);
Intent intent =?new?Intent(ModStudentsActivity.this,AddStudentsActivity.class);
intent.putExtra(“number”, studentsBean.getNumber());
intent.putExtra(“name”, studentsBean.getName());
intent.putExtra(“year”, studentsBean.getYear());
intent.putExtra(“sex”, studentsBean.getSex());
intent.putExtra(“birth”, studentsBean.getBirth());
intent.putExtra(“address”, studentsBean.getAddress());
intent.putExtra(“phone”, studentsBean.getPhone());
ModStudentsActivity.this.startActivityForResult(intent, 1);
}
});
}
}
QueryStudentsActivity類:
public class?QueryStudentsActivity?extends?AppCompatActivity?implements?View.OnClickListener {
ListView?QueryLv;//列表
EditText?EtNumber,?EtName;//輸入框?qū)W號(hào)和姓名
List<StudentsBean>?mData;//數(shù)據(jù)源
Adapter?adapter;//適配器對(duì)象
DbStudents?dbStudents;//數(shù)據(jù)庫(kù)
@Override
protected void?onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_query_students);//綁定所有事件
QueryLv?= findViewById(R.id.query_lv);
EtName?= findViewById(R.id.et_name);
EtNumber?= findViewById(R.id.et_number);
mData?=?new?ArrayList<>();
adapter?=?new?Adapter(this,?mData);
QueryLv.setAdapter(adapter);
dbStudents=new?DbStudents(this);
}
/**
* 按鈕點(diǎn)擊事件
* */
@Override
public void?onClick(View v) {
switch?(v.getId()) {
case?R.id.iv_back:
Intent intent =?new?Intent(QueryStudentsActivity.this, MainActivity.class);
//實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)
startActivity(intent);
finish();
break;
case?R.id.iv_query:
String number =?EtNumber.getText().toString().trim();
String name =?EtName.getText().toString().trim();
if?(TextUtils.isEmpty(number)) {
Toast.makeText(this,?“請(qǐng)輸入學(xué)號(hào)!”, Toast.LENGTH_SHORT).show();
}?else if?(TextUtils.isEmpty(name)) {
Toast.makeText(this,?“請(qǐng)輸入姓名!”, Toast.LENGTH_SHORT).show();
}?else?{
//開(kāi)始搜索
List<StudentsBean> list = DbStudents.getStudentListByNumberAndName(number,name);
mData.clear();//將原來(lái)搜索的消息清除
mData.addAll(list);//顯示在列表上
adapter.notifyDataSetChanged();//實(shí)時(shí)更新
break;
}
}
}
SearchStudentsActivity類:
public class?SearchStudentsActivity?extends?AppCompatActivity?implements?View.OnClickListener {
ImageButton?BtnBack;//退出按鈕
ListView?listView;//列表
List<StudentsBean>?mData;//數(shù)據(jù)源
Adapter?adapter;//適配器
DbStudents?dbStudents;//數(shù)據(jù)庫(kù)
@Override
protected void?onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_students);//綁定事件
BtnBack?= findViewById(R.id.btn_back);
BtnBack.setOnClickListener(this);
listView?= findViewById(R.id.listView);
dbStudents?=?new?DbStudents(this);
mData?=?new?ArrayList<>();
System.out.println(“長(zhǎng)度為:”?+?mData.size());
//設(shè)置適配器:加載每一行數(shù)據(jù)到列表當(dāng)中
adapter?=?new?Adapter(this,?mData);
listView.setAdapter(adapter);
loadData();//顯示學(xué)生信息列表函數(shù)
}
/**
* 顯示學(xué)生信息列表
*/
private void?loadData() {
List<StudentsBean> list = DbStudents.search();
mData.clear();
mData.addAll(list);
adapter.notifyDataSetChanged();//實(shí)時(shí)更新
}
@Override
public void?onClick(View v) {
switch?(v.getId()) {
case?R.id.btn_back:
Intent intent =?new?Intent(SearchStudentsActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
}
}
}
六、數(shù)據(jù)庫(kù)設(shè)計(jì)
七、總結(jié)
這次的課程學(xué)習(xí)時(shí)間比較短,所以完成的項(xiàng)目也不算完美,基礎(chǔ)比較差,到做項(xiàng)目的時(shí)候問(wèn)題就全部出來(lái)了,所以我還需要繼續(xù)努力學(xué)習(xí)。