常州信息职业技术学院18-19学年第1学期
《移动APP开发基础(Android)》课程试卷A答案
一、选择题
1
2
3
4
5
6
7
8
9
10
A
D
B
C
D
A
A
D
C
A
二、判断题
1
2
3
4
5
6
7
8
9
10
T
F
T
F
T
F
F
F
T
F
三、编程题
1.添加按钮事件代码
btn_add.setOnClickListener(newView.OnClickListener(){
@Override
publicvoidonClick(Viewv){
LayoutInflaterinflater=LayoutInflater.from(MainActivity.this);
ViewtextEntryView=inflater.inflate(R.layout.dialoglayout,null);
input_name=(EditText)textEntryView.findViewById(R.id.editText_Name);
AlertDialog.Builderbuilder=newAlertDialog.Builder(MainActivity.this);
builder.setTitle(工人信息);
builder.setView(textEntryView);
builder.setPositiveButton(确定,newDialogInterface.OnClickListener(){
publicvoidonClick(DialogInterfacedialog,intwhichButton){
Stringname=input_name.getText().toString();
SQLiteDatabasedb=openHelper.getWritableDatabase();
db.execSQL(insertintotable_stuvalues(null,?);,newString[]{name});
db.close();
UpdateList();
}});
builder.show();
}
});
2.删除按钮事件代码
btn_delete.setOnClickListener(newView.OnClickListener(){
@Override
publicvoidonClick(Viewv){
LayoutInflaterinflater=LayoutInflater.from(MainActivity.this);
ViewtextEntryView=inflater.inflate(R.layout.dialoglayout,null);
input_name=(EditText)textEntryView.findViewById(R.id.editText_Name);
AlertDialog.Builderbuilder=newAlertDialog.Builder(MainActivity.this);
builder.setTitle(工人信息);
builder.setView(textEntryView);
builder.setPositiveButton(确定,newDialogInterface.OnClickListener(){
publicvoidonClick(DialogInterfacedialog,intwhichButton){
Stringname=input_name.getText().toString();
SQLiteDatabasedb=openHelper.getWritableDatabase();
db.execSQL(deletefromtable_stuwherename=?;,newString[]{name});
db.close();
UpdateList();