网站建设套餐有哪些内容wordpress转盘
目录
- 第一章 认识Android
 - 第二章 Android常见界面布局
 - 第三章 Android常用基本控件
 - 第四章 Android 高级控件
 - 第五章 Android菜单和对话框
 
第一章 认识Android
1. Android 界面设计被称为______。
 答案:布局
 2. Android中常见的布局包括______、______ 、______ 、______ 、______ 五种。
- 相对布局RelativeLayout
 - 线性布局LinearLayout
 - 表格布局TableLayout
 - 网格布局GirdLLayout
 - 帧布局FrameLayout。
 
3. 什么是dp,px,sp?
- dp:设备独立像素
 - px:像素
 - sp:放大像素
 
必考:Android应用程序结构:
- src:存放程序源代码
 - gen:系统自动生成,无需手动修改。最重要的就是R.java文件,保存了程序中断用到的所有控件和资源的ID。
 - assets:存放不进行编译和加工的原生文件,这里的资源文件不会再 R.java 自动生成 ID。
 - drawable-hdpi:存放高分辨率图片。
 - drawable-ldpi:存放低分辨率图片。
 - drawable-mdpi:存放中分辨率图片。
 - drawable-xhdpi:存放超高分辨率图片。
 - layout:项目的布局文件,就是应用程序界面的XML文件。
 - menu:菜单文件,同样为XML格式,在此可以为应用程序添加菜单。
 - values:该目录存放的XML文件,定义了各种格式的键值对
 - AndroidManifest.xml:这是程序的清单文件。应用程序的所有组件,都需要早该文件中进行注册,否则程序无法识别,不能使用。
 
第二章 Android常见界面布局
4. 相对布局分为______ 、______ 两种。
- 相对父容器布局
 - 相对控件布局
 
5.相对父容器布局的使用。在相对布局中添加一个Button,在父容器中水平居中,Button顶端与父容器上边框对齐,Button上边缘距父容器上边缘64dp
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context="${relativePackage}.${activityClass}" ><!-- Button控件margin:距离  alignParentTop:对齐顶部centerHorizontal:中心水平--><Buttonandroid:id = "@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentTop="true"android:layout_centerHorizontal="true"android:layout_marginTop = "64dp"android:text="@string/button1"/>
</RelativeLayout>
 
6. 相对控件布局的使用。添加一个Button2位于Button1右下方,并且设置Buttton2上边缘距Button1 38dp。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentTop="true"android:layout_centerHorizontal="true"android:layout_marginTop="64dp"android:text="@string/button1" /><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/button1"android:layout_marginTop="38dp"android:layout_toRightOf="@+id/button1"android:text="@string/button2" /></RelativeLayout> 
7. 线性布局可以分为______ 、 ______ 两种。
- 水平线性布局
 - 垂直线性布局
 
8. 水平线性布局的使用
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" android:orientation = "horizontal"</LinearLayout 
 
9.垂直线性布局的使用
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" android:orientation="vertical">//修改布局-当前为垂直<Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/button1" /><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/button2" /></LinearLayout>
 
第三章 Android常用基本控件
10. Android常用基本控件有______ 、 ______ 、 ______ 、 ______ 、 ______ 、 ______ 。
- TextView(文本框)
 - EditText(编辑框)
 - Button(按钮)
 - CheckBox(多选按钮)
 - RadioButton(单选按钮)
 
11. 在布局文件中声明的控件,只负责界面显示。如果要想使用控件实现某些具体功能,就需要在Activety中编辑代码实现。实现过程如下:
- 使用xxx来加载布局文件
 - 使用xxx获取控件引用
 - 使用这个引用对控件进行操作
 
12. 文本类控件主要用于在界面中显示文本, 包含______ 、______两种。
- TextView
 - EditView
 
13. Button类控件主要包括______ 、 ______ 、 ______ 、 ______ 、 ______ 五种。
- Button
 - ImageButton
 - ToggleButton
 - RadioButton
 - CheckBox
 
14. 为Button注册监听的两种办法
- 逻辑代码中编写OnClick方法
 - 布局代码中绑定匿名监听器,并重写click方法
 
layout 布局代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><Button android:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/button1"/><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_marginTop="60dp"android:onClick="click"android:text="@string/button2" /></RelativeLayout>
 
逻辑代码
package com.example.button;import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class MainActivity extends Activity {Button button1,button2;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button1 = (Button)findViewById(R.id.button1);button2 = (Button)findViewById(R.id.button2);button1 .setOnClickListener(new OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stubsetTitle("Button1注册成功");}});}public void click(View v) { setTitle("Button2注册成功");}    }
 
15. ToggleButton的使用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><ToggleButtonandroid:id="@+id/toggleButton1"android:layout_width="1500dp"android:layout_height="80dp"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"    android:textOn="开"  android:textOff="关"/></RelativeLayout>
 
16. RadioButton的使用:选择坐飞机还是坐轮船
 布局代码如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/LinearLayout1"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><TextView android:id="@+id/tv1"android:layout_width="wrap_content"android:layout_height="wrap_content"  android:textSize="30sp"android:text="请选择:" /><RadioGroupandroid:id="@+id/rg1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical" ><RadioButtonandroid:id="@+id/rb1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="30sp"android:text="火车" /><RadioButtonandroid:id="@+id/rb2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="30sp"android:text="飞机" /></RadioGroup><TextView android:id="@+id/tv2"android:layout_width="wrap_content"android:layout_height="wrap_content"  android:textSize="30sp"android:text="您选择的是:" />
</LinearLayout>
 
关键逻辑代码
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {public void onCheckedChanged(RadioGroup group, int checkedId) {// TODO Auto-generated method stubif (checkedId == R.id.rb1) {textView.setText("您选择的是:" + radioButton1.getText());}else {textView.setText("您选择的是:" + radioButton2.getText());}}
});
 
17.时钟控件包括______和______,前者______时钟,只显示分和秒,后者显示______时钟,可精确到秒
- AnalogClock
 - DigitalClock
 - 模拟
 - 数字
 
第四章 Android 高级控件
18. 进度条有______ 、______ 、______ 、______ 四种。
- Large
 - Normal
 - Small
 - Horizontal
 
19. ProgressBar 的属性表
| 属性名称 | 属性说明 | 
|---|---|
| style | 设置进度条样式 | 
| max | 进度条的最大进度值 | 
| progress | 第一进度值 | 
| secondaryProgress | 次要进度值 | 
20. ProgressBar 的使用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><ProgressBarandroid:id="@+id/progressBar1"style="?android:attr/progressBarStyleHorizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentRight="true"android:layout_alignParentTop="true"android:layout_marginTop="36dp"android:max="100"android:progress="75"android:secondaryProgress="50" /><ProgressBarandroid:id="@+id/progressBar2"style="?android:attr/progressBarStyleSmall"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/progressBar1"android:layout_marginTop="24dp" /><ProgressBarandroid:id="@+id/progressBar3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/progressBar2"android:layout_marginTop="76dp" /><ProgressBarandroid:id="@+id/progressBar4"style="?android:attr/progressBarStyleLarge"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/progressBar3"android:layout_marginTop="62dp" /></RelativeLayout>
 
21. SeekBar的使用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><SeekBarandroid:id="@+id/seekBar1"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginTop="93dp" android:thumb="@android:drawable/btn_star_big_on"      android:max="100"  android:progress="25"     /><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/seekBar1"android:layout_marginLeft="40dp" android:text="当前进度值为:25"/></RelativeLayout>
 
关键代码:
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {public void onStopTrackingTouch(SeekBar seekBar) {// TODO Auto-generated method stub}public void onStartTrackingTouch(SeekBar seekBar) {// TODO Auto-generated method stub}public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {// TODO Auto-generated method stubtextView.setText("褰撳墠杩涘害鍊硷細" + progress);}});
 
22. RatingBar的使用
 布局代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><RatingBarandroid:id="@+id/ratingBar1"style="?android:attr/ratingBarStyle"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginTop="14dp" android:numStars="5"android:rating="4.0"android:stepSize="0.5"/><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/ratingBar1" android:layout_marginTop="20dp"android:text="受欢迎度:4.0颗星"/></RelativeLayout> 
逻辑代码如下:
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {public void onRatingChanged(RatingBar ratingBar, float rating,boolean fromUser) {// TODO Auto-generated method stubtextView.setText("受欢迎度为:" + rating + "颗星");}});
 
第五章 Android菜单和对话框
23. 菜单分为3类:______ 、______ 和______ 。
- 选项菜单(Options Menu)
 - 上下文菜单(Context Menu)
 - 子菜单(Submene)
 
24. 对话框主要包括______ 、______ 、______ 、______ 、______ 、______ 等
- 普通对话框
 - 提示对话框
 - 单选和复选对话框
 - 列表对话框
 - 进度对话框
 - 日期与时间对话框
 
25. 提示对话框AlertDialog的使用
 逻辑代码如下
package com.example.alertdialog;import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;public class AlertDialogActivity extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);AlertDialog.Builder builder=new AlertDialog.Builder(this);builder.setIcon(android.R.drawable.ic_dialog_info);builder.setTitle("AlertDialog");builder .setMessage("你确定删除吗");builder.setPositiveButton("确定", new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialog, int which) {setTitle("确定");				}        	});builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {setTitle("取消");			}});builder.show();}}
 
26. 什么是Toast
 略
27. Toast的使用(必考!)
28. 开发Notification,主要涉及哪三个类?
- Notification.Builder:一般用于动态地设置 Notification 的一些属性,即用 set 类设置;
 - NotificationManager:主要负责将 Notification 在状态栏中显示和取消;
 - Notification:主要用于设置 Notification 的相关属性。
 
