android试卷A及答案
更新时间:2024-05-24 21:58:01 阅读量: 综合文库 文档下载
Android应用试卷A
一、选择题(10分)
1. 下列不是手机操作系统的是?(D) A. Android B. Window Mobile C. Apple IPhone IOS D. windows vista
2. 下列选项哪个不是Activity启动的方法?( B ) A. startActivity B. goToActivity C. startActivityForResult D. startActivityFromChild
3. 下列哪个不是Activity的生命周期方法之一?( B ) A. onCreate B. startActivity C. onStart D. onResume
4. 下列哪个可做Android数据存储?( A ) A. SQlite B. MySql C. Oracle D. DB2
5. 下列哪个可做EditText编辑框的提示信息?( D ) A. android:inputType B. android:text C. android:digits D. android:hint
二、真空题(20分)
1. 为了使android适应不同分辨率机型,布局时字体单位应用 sp ,像素单位应用 sp 和 dip 。
2. 定义LinearLayout水平方向布局时至少设置的三个属性: android:orientation , android:layout_width 和 android:layout_height 。
3. 设置 ImageView控件为灰色的方法是: android:background=”#040” 。
4. layout布局文件的命名不能出现字母 大写 。 5. 设置EditText只能输入” 1234567890.+-*/%()”属性: android:digits 。
6. 设置TextView字体的属性是: android:textSize 。
三、简答题(30分)
1. Android项目中的入口Activity怎么写?如何注册一般的Activity? (1) Android项目中的入口Activity:
xmlns:android=\\ package=\ android:versionCode=\ android:versionName=\> android:name=\ /> android:name=\ />
2. 列举通过Intent传递不同数据类型的方法(至少5个)? ①Intent.addCategory(String category) ②Intetn.addFlags(int flags) ③Intent.equals(Object o)
④Intent.fillIn(Intent other,int flags) ⑤Intent.filterEquals(Intent other)
3. 请介绍下Android中常用几种布局(至少3种,多一个加2分)?
线性布局LinearLayout,相对布局RelativeLayout,表单布局TableLayout,
帧布局FrameLayout,列表布局:listview,表格布局:gridview,绝对布局:absoluteLayout, 标签布局:tablayout
4. 阐述android:padding和android:layout_margin的异同?
(1)不同点:android:padding 是站在父View 的角度描述问题,它规定它里面的内容必须与这个父View 边界的距离。android:layout_margin 则是站在自己角度描述问题,规定自己和其他(上下左右)的 View 之间的距离如同一级只有一个View,那么他的效果基本上就和padding一样。(2)相同点:如同一级只有一个View,那么android:layout_margin的效果基本上就和android:padding一样
5. 列举TextView控件中的10个属性?
①android:text
②android:hint
③android:textColor ④android:textSize ⑤android:bufferType ⑥android:maxLines ⑦android:lines
⑧android:layout_width ⑨android:layout_height ⑩android:layout_gravity
四、编程题(40分)
1. 写出按钮和按钮单击事件(6分)
布局文件 :main.xml
xmlns:android=\\ android:layout_width=\ android:layout_height=\ > android:layout_width=\ android:layout_height=\ android:text=\计算你的标准体重\ android:id=\ android:textSize=\ android:layout_centerHorizontal=\ android:layout_marginTop=\ /> android:layout_width=\ android:layout_height=\ android:text=\性别:\ android:layout_below=\ android:layout_marginTop=\ android:id=\ /> android:layout_width=\ android:layout_height=\ android:orientation=\ android:id=\ android:layout_below=\ android:checkedButton=\ > android:layout_width=\ android:layout_height=\ android:id=\ android:text=\男\ /> android:layout_width=\ android:layout_height=\ android:text=\女\ android:id=\ /> android:layout_width=\ android:layout_height=\ android:text=\身高:\ android:layout_below=\ android:layout_marginTop=\ android:id=\ /> android:layout_width=\ android:layout_height=\ android:layout_below=\ android:id=\ />
Activity:MainActivity.java
import android.app.MainActivity; import android.app.AlertDialog;
import android.content.DialogInterface; import android.os.Bundle; import android.view.View;
import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton;
public class MainActivity extends Activity {
/** Called when the activity is first created. */ @Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.btn);
btn.setOnClickListener(btnClickListener); }
OnClickListener btnClickListener = new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub RadioButton male = (RadioButton)findViewById(R.id.male);
//sex=1 代表男性 //sex=2 代表女性
int sex = male.isChecked()?1:2;
EditText et = (EditText)findViewById(R.id.height);
//得到用户输入的身高
float height =
Float.parseFloat(et.getEditableText().toString());
float weight = getWeight(sex, height);
new AlertDialog.Builder(Main.this)
.setTitle(\体重\
.setMessage(\您的标准体重为\.setPositiveButton(\确定\new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).show(); } };
//此方法用来计算标准体重
}
public float getWeight(int sex,float height){
float weight = 0.0f;
if (sex==1) {
weight = (height - 80) * 0.7f; } else {
weight = (height - 70) * 0.6f; }
return Math.round(weight); }
2. 写出按钮和按钮单击后跳转到另一个Activity(6分)
布局文件 :main.xml(写出完整控件即可)
xmlns:android=\\ android:orientation=\ android:layout_width=\ android:layout_height=\ android:background=\ > android:layout_width=\ android:layout_height=\ android:text=\ android:layout_gravity=\ android:textSize=\ android:textColor=\ android:layout_marginTop=\ android:layout_marginBottom=\ android:textStyle=\ /> android:layout_width=\ android:layout_height=\ android:background=\ android:layout_marginLeft=\ android:layout_marginRight=\ />
Activity:MainActivity.java(跳转目标OtherActivity.java)(写出关键代码即可)
import junit.framework.MainActivity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View;
import android.view.View.OnClickListener; import android.widget.Button;
public class MainActivity extends Activity { Button wel_btn1; Button wel_btn2; Button wel_btn3;
/** Called when the activity is first created. */ @Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
wel_btn1=(Button)findViewById(R.id.wel_btn1); wel_btn2=(Button)findViewById(R.id.wel_btn2); wel_btn3=(Button)findViewById(R.id.wel_btn3);
wel_btn1.setOnClickListener(onClickListener); wel_btn2.setOnClickListener(onClickListener); wel_btn3.setOnClickListener(onClickListener); }
OnClickListener onClickListener=new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub MainActivity.this.finish(); Intent intent=new
Intent(MainActivity.this,OtherActivity.class);
}
startActivity(intent); } };
3. 写出加1 和 减1的程序主要代码(6分)
布局文件 :main.xml
- android:layout_width=\wrap_content\ android:layout_height=\wrap_content\ android:text=\每天运动:\ android:gravity=\left\18sp\ android:id=\@+id/add\ android:layout_width=\wrap_content\ android:layout_height=\wrap_content\ android:background=\@drawable/btn_add\ android:textSize=\24sp\ android:id=\@+id/result\ android:layout_width=\90dip\ android:layout_height=\wrap_content\ android:textSize=\18sp\ android:background=\#fff\ android:id=\@+id/less\ android:layout_width=\wrap_content\ android:layout_height=\wrap_content\ android:background=\@drawable/btn_less\ android:textSize=\24sp\
Activity:MainActivity.java
import android.app.MainActivity; import android.os.Bundle; import android.view.View;
import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView;
public class MainActivity extends Activity { TextView textView; int temp = 0;
/** Called when the activity is first created. */ @Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.button);
Button addButton = (Button) findViewById(R.id.add); addButton.setOnClickListener(onClickListener);
Button lessButton = (Button) findViewById(R.id.less); lessButton.setOnClickListener(onClickListener);
textView = (TextView) findViewById(R.id.result); textView.setText(\分钟/天\ }
OnClickListener onClickListener = new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub if(v.getId() == R.id.add){ temp += 5; textView.setText(temp+\分钟/天\ }else if(v.getId() == R.id.less){ temp -= 5; textView.setText(temp+\分钟/天\ } } }; }
4. 写出按钮点击和非点击状态图片切换的那个btn_login.xml文件代码(6分) (图片:btn_login_nor.png,btn_login_on.png)
xmlns:android=\\
android:drawable=\ btn_login_nor \ 5. 只写出猜纸牌游戏中的点击第一张进行猜牌的功能代码?(6分) 布局文件 :main.xml xmlns:android=\\ android:orientation=\ android:layout_width=\ android:layout_height=\ > android:layout_width=\ android:layout_height=\ android:text=\猜猜看红心A是哪一张?\ android:textSize=\ android:layout_marginTop=\ android:layout_marginLeft=\ android:id=\ /> xmlns:android=\\ android:orientation=\ android:layout_width=\ android:layout_height=\ android:layout_marginTop=\ android:layout_marginLeft=\ > android:layout_width=\ android:layout_height=\ android:src=\ android:id=\ /> android:layout_width=\ android:layout_height=\ android:src=\ android:layout_marginLeft=\ android:layout_marginRight=\ android:id=\ /> android:layout_width=\ android:layout_height=\ android:src=\ android:id=\ /> android:layout_width=\ android:layout_height=\ android:text=\再玩一次\ android:layout_marginTop=\ android:layout_gravity=\ android:paddingLeft=\ android:paddingRight=\ android:id=\ /> Activity:MainActivity.java import java.util.Arrays; import java.util.Collections; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; public class Guess extends Activity { List Arrays.asList(R.drawable.p01,R.drawable.p02,R.drawable.p03); boolean enable = true; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView img1 = (ImageView)findViewById(R.id.img1); ImageView img2 = (ImageView)findViewById(R.id.img2); ImageView img3 = (ImageView)findViewById(R.id.img3); img1.setOnClickListener(imgClickListener); Button btn = (Button)findViewById(R.id.btn); btn.setOnClickListener(btnListener); } OnClickListener btnListener = new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub ImageView img1 = (ImageView)findViewById(R.id.img1); ImageView img2 = (ImageView)findViewById(R.id.img2); ImageView img3 = (ImageView)findViewById(R.id.img3); img1.setImageResource(R.drawable.p04); img2.setImageResource(R.drawable.p04); img3.setImageResource(R.drawable.p04); img1.setAlpha(255); img2.setAlpha(100); img3.setAlpha(100); TextView result = (TextView)findViewById(R.id.result); result.setText(\猜猜看红心A是哪一张?\ } }; } 6. 写一个注册页面,不包含后台验证(自己发挥)(10分) 要求:a.注册项:用户名、账号、密码、性别、出生年月日、爱好、手机和注册按钮 b.用户名框只能输入字母和下划线,宽度为200像素 c. 账号框只能输入数字,宽度为200像素 d.密码框要用设置对应属性(即不可显示),宽度为200像素 e.性别用单选框,默认选中男 f.出生年日月用日期控件,默认当前日期 g.爱好用多选框,默认选中第二个选项。(篮球、足球、下棋、游泳) h.手机框只能输入数字,宽度为200像素 i.整个页面要居中
正在阅读:
android试卷A及答案05-24
浅析中国服务业对国民经济发展与影响02-29
安全教育培训记录表06-01
2011年3月计算机一级MSOffice真题及答案08-15
广东省汕头市潮南区名校2018年初中语文毕业生学业考试模拟试题06-25
Matlab模拟退火算法06-07
霍尔传感器测速208-27
三年级上册数学应用题100道09-30
医院药物遴选原则及药品09-10
观摩课教学活动总结05-07
- 2009中西部家居博览会总体策划
- 2009 Revit 1级工程师学生用
- 天津地铁建设工程试验检测机构管理办法(TJDT-ZY-AQ-29)
- 新四年级数学暑期班第七次教案
- 机械制造企业隐患排查治理检查表 - 图文
- 2008届全国百套高考数学模拟试题分类汇编-103概率与统计解答题 -
- 职场健身防病试题及答案
- Excel操作技巧大全II - --数据输入和编辑技巧
- 南开大学2018春季《行政管理学》离线作业考核答案
- 2015年医师定考简易程序试卷及答案
- 新《预算法》对行政事业单位预算管理的挑战解读
- 轴的课件
- 电动汽车充电桩设计 毕业论文
- 必修2、选修2-1、1-1期末模拟试题2
- 桌面远程运维管理系统实施-可行性研究报告120306
- 西气东输水土保持工程工作总结 - 图文
- 正宁县基本县情及经济社会发展情况简介
- SATWE参数设置(巨详细)
- 儒家法思想研究综述
- 生活家政服务电子商务平台建设运营整合方案书【审报完稿】
- 试卷
- 答案
- android
- 人教版七年级下册思想政治复习资料1
- 模具CADCAECAM课程设计说明书 - 图文
- 零中介留学:澳洲大学法学
- 09级园艺专业生化复习题
- 脚手架施工方案 改1
- 机遇更重要——在人生道路上机遇更重要还是奋斗更重要?(我打辩
- 经营者安全保障义务的合理限度
- 最新年铁一中小升初综合素质评价模拟试卷
- 国开电大人文英语1单元自测3Unit3 Self-test
- 浅谈电力设备检修现状及完善对策
- 第14单元《勾股定理》导学案2
- 公共管理导论第1次作业
- 桥梁工程毕业设计 - 图文
- 微机原理实验三
- 汇总计算机体系结构总复习 - 图文
- 党在我心中0
- 江西省高速公路施工质量控制要点
- 管理学院学生会章程
- 中国机制木炭行业市场前景分析预测年度报告(目录) - 图文
- 2012广西壮族自治区教师资格证考试笔试考试题库