




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Android应用试卷A一、选择题(10分)1. 下列不是手机操作系统的是(D)A. AndroidB. Window MobileC. Apple IPhone IOSD. windows vista2. 下列选项哪个不是Activity启动的方法( B )A. startActivityB. goToActivityC. startActivityForResultD. startActivityFromChild3. 下列哪个不是Activity的生命周期方法之一( B )A. onCreateB. startActivityC. onStartD. onResume4. 下列哪个可做A
2、ndroid数据存储( A )A. SQliteB. MySqlC. OracleD. DB25. 下列哪个可做EditText编辑框的提示信息( D )A. android:inputTypeB. android:textC. android:digits D. android:hint二、真空题(20分)1. 为了使android适应不同分辨率机型,布局时字体单位应用sp,像素单位应用sp和dip2. 定义LinearLayout水平方向布局时至少设置的三个属性:android:orientation,android:layout_width和android:layout_height。3
3、. 设置ImageView控件为灰色的方法是:android:background=”#040” 4. layout布局文件的命名不能出现 字母大写。5. 设置EditText只能输入” 90.+-*/%()”属性:android:digits。6. 设置TextView字体的属性是:android:textSize。三、简答题(30分)1. Android项目中的入口Activity怎么写?如何注册一般的Activity(1) Android项目中的入口Activity:<?xml version="1.0" encoding="utf-8"&g
4、t;<manifest xmlns:android=" package="com.test" android:versionCode="1" android:versionName="1.0"> <application android:icon="drawable/icon" android:label="string/app_name"> <activity android:name=".WelcomeActivity" andro
5、id:label="string/app_name"> <intent-filter> <action android:name="ent.action.MAIN" /> <category android:name="ent.category.LAUNCHER" /> </intent-filter>(2) 注册一般的Activity: </activity> <activity android:name="
6、.test"/> </application> <uses-sdk android:minSdkVersion="6" /></manifest>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. 请介绍下
7、Android中常用几种布局(至少3种,多一个加2分)线性布局LinearLayout,相对布局RelativeLayout,表单布局TableLayout,帧布局FrameLayout,列表布局:listview,表格布局:gridview,绝对布局:absoluteLayout,标签布局:tablayout4. 阐述android:padding和android:layout_margin的异同?(1)不同点:android:padding 是站在父View 的角度描述问题,它规定它里面的内容必须与这个父View 边界的距离。android:layout_margin 则是站在自己角度描述
8、问题,规定自己和其他(上下左右)的 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_
9、height android:layout_gravity四、编程题(40分)1. 写出按钮和按钮单击事件(6分)布局文件 :main.xml<?xml version="1.0" encoding="utf-8"><RelativeLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_wid
10、th="wrap_content" android:layout_height="wrap_content" android:text="计算你的标准体重" android:id="+id/title" android:textSize="20sp" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" /><TextView android:layout_
11、width="wrap_content" android:layout_height="wrap_content" android:text="性别:" android:layout_below="+id/title" android:layout_marginTop="20dp" android:id="+id/sextitle"/><RadioGroupandroid:layout_width="wrap_content" android:
12、layout_height="wrap_content" android:orientation="horizontal" android:id="+id/sexgroup" android:layout_below="+id/sextitle" android:checkedButton="+id/male"><RadioButton android:layout_width="wrap_content" android:layout_height="
13、wrap_content" android:id="+id/male" android:text="男"/><RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="女" android:id="+id/female"/></RadioGroup><TextView android:layo
14、ut_width="wrap_content" android:layout_height="wrap_content" android:text="身高:" android:layout_below="+id/sexgroup" android:layout_marginTop="20dp" android:id="+id/heighttitle"/><EditText android:layout_width="200dp" android
15、:layout_height="wrap_content" android:layout_below="+id/heighttitle" android:id="+id/height"/><Buttonandroid:layout_width="wrap_content" android:layout_height="wrap_content" android:text="计算" android:layout_below="+id/height"
16、; android:id="+id/btn" android:layout_marginTop="20dp" android:paddingLeft="20dp" android:paddingRight="20dp"/></RelativeLayout>Activity:MainActivity.javaimport android.app.MainActivity;import android.app.AlertDialog;import android.content.DialogInter
17、face;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 vo
18、id 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
19、method stubRadioButton 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.Bui
20、lder(Main.this).setTitle("体重").setMessage("您的标准体重为"+weight).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=
21、1) weight = (height - 80) * 0.7f; else weight = (height - 70) * 0.6f;return Math.round(weight);2. 写出按钮和按钮单击后跳转到另一个Activity(6分)布局文件 :main.xml(写出完整控件即可)<?xml version="1.0" encoding="utf-8"><LinearLayout xmlns:android=" android:orientation="vertical" android:
22、layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff" ><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="string/welcome_title" android:layout_gravity=&q
23、uot;center" android:textSize="24sp" android:textColor="#000" android:layout_marginTop="10dip" android:layout_marginBottom="10dip" android:textStyle="bold" /> <ImageView android:layout_width="wrap_content" android:layout_height=&q
24、uot;140dip" android:background="drawable/bg_welcome" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" /> <Button android:id="+id/wel_btn1" android:layout_width="140dip" android:layout_height="wrap_content" and
25、roid:text="string/welcome_btn1" android:layout_gravity="center_horizontal" android:layout_marginTop="10dip" android:padding="1dip" /> <Button android:id="+id/wel_btn2" android:layout_width="140dip" android:layout_height="wrap_con
26、tent" android:text="string/welcome_btn2" android:layout_gravity="center_horizontal" android:layout_marginTop="10dip" android:padding="1dip" /> <Button android:id="+id/wel_btn3" android:layout_width="140dip" android:layout_height=
27、"wrap_content" android:text="string/welcome_btn3" android:layout_gravity="center_horizontal" android:layout_marginTop="10dip" android:padding="1dip" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_con
28、tent" android:text="string/welcome_address" android:layout_gravity="right" android:textSize="15sp" android:textColor="#000" android:layout_marginRight="10dip" android:layout_marginTop="30dip" android:textStyle="italic" />&
29、lt;/LinearLayout>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
30、 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_
31、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 vo
32、id onClick(View v) / TODO Auto-generated method stubMainActivity.this.finish();Intent intent=new Intent(MainActivity.this,OtherActivity.class);startActivity(intent);3. 写出加1 和 减1的程序主要代码(6分)布局文件 :main.xml <xml version="1.0" encoding="utf-8" > - <LinearLayout xmlns:an
33、droid=" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="每天运动:" android
34、:gravity="left" android:textSize="18sp" /> <Button android:id="+id/add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="drawable/btn_add" android:textSize="24sp" />
35、0;<TextView android:id="+id/result" android:layout_width="90dip" android:layout_height="wrap_content" android:textSize="18sp" android:background="#fff" /> <Button android:id="+id/less" android:layout_width="wrap_content&
36、quot; android:layout_height="wrap_content" android:background="drawable/btn_less" android:textSize="24sp" /> </LinearLayout>Activity:MainActivity.javaimport android.app.MainActivity;import android.os.Bundle;import android.view.View;import android.view.Vi
37、ew.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); setC
38、ontentView(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(&quo
39、t;0分钟/天"); OnClickListener onClickListener = new OnClickListener() public void onClick(View v) / TODO Auto-generated method stubif(v.getId() = R.id.add)temp += 5;textView.setText(temp+"分钟/天");else if(v.getId() = R.id.less)temp -= 5;textView.setText(temp+"分钟/天");4. 写出按钮点击和非点击
40、状态图片切换的那个btn_login.xml文件代码(6分)(图片:btn_login_nor.png,btn_login_on.png)<?xml version="1.0" encoding="UTF-8"><selector xmlns:android=" <item android:state_pressed="true" android:drawable="drawable/ btn_login_nor " /> <item android:drawable=
41、"drawable/ btn_login_on" /></selector>5. 只写出猜纸牌游戏中的点击第一张进行猜牌的功能代码(6分)布局文件 :main.xml<?xml version="1.0" encoding="utf-8"><LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:lay
42、out_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="猜猜看红心A是哪一张" android:textSize="20sp" android:layout_marginTop="20dp" android:layout_marginLeft="20dp" a
43、ndroid:id="+id/result" /><LinearLayout xmlns:android=" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="60dp" android:layout_marginLeft="20dp" >
44、 <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="drawable/p04" android:id="+id/img1" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:sr
45、c="drawable/p04" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" android:id="+id/img2" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="drawable/p04" andr
46、oid:id="+id/img3" /></LinearLayout><Buttonandroid:layout_width="wrap_content" android:layout_height="wrap_content" android:text="再玩一次" android:layout_marginTop="80dp" android:layout_gravity="center" android:paddingLeft="30dp" android:paddingRight="30dp" android:id="+id/btn"/></LinearLayout>Activity:MainActivity.javaimport java.util.Arrays;import java.util.Collections;import java.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 隐性股东持股协议书
- 餐饮联名露营协议书
- 便利店代销产品协议书
- 餐饮转让订金协议书
- 项目外包服务协议书
- 门面赠与父母协议书
- 出售天然砂石枓协议书
- 运营团队保密协议书
- 起诉撤销调解协议书
- 保洁员劳务派遣协议书
- MOOC 创业管理-江苏大学 中国大学慕课答案
- (高级)政工师理论考试题库及答案(含各题型)
- 建筑给水排水及采暖工程施工质量验收规范-培训课件
- 深圳工改工最新政策研究
- 煤矿自动化(培训)
- 肖申克的救赎 英语三分钟演讲-文档资料
- 颅内肿瘤的护理(课堂PPT)
- 国家开放大学《生产与运作管理》形考作业1-4参考答案
- 九年级化学中考第二轮复习--八大专题人教版
- XIRR测算公式本金(模板)
- 铝塑板门头干挂铝塑板施工方案
评论
0/150
提交评论