day01总结
来源:互联网 发布:图片去码软件 编辑:程序博客网 时间:2024/04/30 08:43
1.我们所说的3G 4G一般值得是通信技术的代数,G--既是generation,每一代通信技术有不同的特点,
1G是模拟信号,通话质量差;2G能满足基本的通话;2.5G又叫GPRS,有低速上网服务;2.75G又叫EDGE,上网速度比GPRS稍快
3G上网可达300KB/S,3G中又有几个引申的3.5G 3.75G 上网速度越来越快.可达到42M/s,到了4G时代,网速更是快的不行
然而流量费的高价也是不容忽视的;华为已经自主研发并获取了5G的专利.
2.安卓的体系结构主要分为四大部分.a.应用层(application) b.应用程序框架层(application framework)
c.核心代码库(libraries) 这部分是由C或者C++编写的源代码 d.Linux kernel 这个是Linux的内核,驱动硬件.
举个例子:一个闹钟的应用程序,在我设定了闹钟以后, 在到点以后,应用程序会调用框架层的notification framework(通知)
,再由通知框架调用media相关的核心代码,再由核心代码调用audio Driver 驱动喇叭发出声音完成响铃的效果.
3.JVM是java virtual machine 的简称,java代码运行时先要将.java文件编译成.class字节码文件,然后再运行
而Dalvik VM则是安卓的虚拟机,它会一次性将所有的代码编译为dex文件,在效率上比JVM快,其次DVM是google研发的,JVM是SUN公司研发的
后被甲骨文收购.在android4.4以后多了一个ART模式,采用ART模式时,安装软件是会将软件进行预编译,这样大大提高了软件的运行速度.
在硬件上,JVM基于栈内存,而DVM基于寄存器,基于寄存器的虚拟机对于运行变异后更大的程序来说,运行速度更快.
4.Android工程的目录结构,主要需要着重记忆的是四个位置,记88个字(父母之命媒妁之言)
a.gen文件夹里的R文件 这个相当于媒人,里面存储了一些对象的id,在关心控件时getViewById(id)
b.项目根目录下的AndroidManifest.xml文件 相当于父母, 里面可以配置项目的权限(目前只用到这些)
c.layout(res-drawable下) 妹子 布局文件,显示给人看的
d.src下的mainAcitvity.java文件 汉子 业务逻辑都写在这个文件里
关系:R文件联系layout文件和mainActivity文件,由manifest.xml文件提供权限
5.安卓项目的开发流程:
a.首先写布局文件,创建布局文件;
b.在java文件中写好业务逻辑, View v= findViewById()得到关心控件;
c.关联好时间,一般为点击事件 通过关心控件v.setOnclickListener() 设置点击监听
参数需要一个OnClickListener的子类对象(对象自动调用其onclick方法)
在这里我们采用的方法是写一个内部类实现了OnclickListener接口,复写其onclick方法,完成一些逻辑代码.
d.最后需要在xml文件中给项目添加对应的权限,否则程序点击后会报错.
6.拨号器的完成
a.完成布局文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button1"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="1"
/>
<Button
android:id="@+id/button2"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="2"
/>
<Button
android:id="@+id/button3"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="3"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button4"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="4"
/>
<Button
android:id="@+id/button5"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="5"
/>
<Button
android:id="@+id/button6"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="6"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button7"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="7"
/>
<Button
android:id="@+id/button8"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="8"
/>
<Button
android:id="@+id/button9"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="9"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button_xing"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="*"
/>
<Button
android:id="@+id/button0"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="0"
/>
<Button
android:id="@+id/button_jing"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="#"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="2">
<Button
android:id="@+id/button_call"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_below="@id/button0"
android:text="拨号" />
<Button
android:id="@+id/button_clear"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_toLeftOf="@id/button_call"
android:text="清空" />
<Button
android:id="@+id/button_delete"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/button_call"
android:text="删除" />
</RelativeLayout>
</LinearLayout>
b.业务逻辑
在写内部类的时候要在onclick方法中创建一个意图Intent intent=new Intent(),通过对意图设置动作
intent.setAction(Intent.ACTION_CALL) 参数是Intent类里的静态常量 设置万动作以后还要设置数据
intent.setData(Uri.parse("tel://110")) 参数是统一资源标识符 uri 将电话号码经过转换后可以添加进去
另外的重点就是Edit_Text对象的setText()方法,参数为String getText().toString().trim()得到去重的字符串
package com.heima.call;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.text.Editable;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
static EditText edit_text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.show);
//查找EditText控件
edit_text = (EditText) findViewById(R.id.edit_text);
//创建其他按钮点击
//首先获取按钮控件
/*for (i = 1; i < 10; i++) {
button = (Button) findViewById(0x7f080000+i);
//绑定点击事件监听
}*/
Button button0=(Button) findViewById(R.id.button0);
Button button1=(Button) findViewById(R.id.button1);
Button button2=(Button) findViewById(R.id.button2);
Button button3=(Button) findViewById(R.id.button3);
Button button4=(Button) findViewById(R.id.button4);
Button button5=(Button) findViewById(R.id.button5);
Button button6=(Button) findViewById(R.id.button6);
Button button7=(Button) findViewById(R.id.button7);
Button button8=(Button) findViewById(R.id.button8);
Button button9=(Button) findViewById(R.id.button9);
Button button_xing=(Button) findViewById(R.id.button_xing);
Button button_jing=(Button) findViewById(R.id.button_jing);
Button button_clear=(Button) findViewById(R.id.button_clear);
Button button_delete=(Button) findViewById(R.id.button_delete);
button0.setOnClickListener(new Click("0"));
button1.setOnClickListener(new Click("1"));
button2.setOnClickListener(new Click("2"));
button3.setOnClickListener(new Click("3"));
button4.setOnClickListener(new Click("4"));
button5.setOnClickListener(new Click("5"));
button6.setOnClickListener(new Click("6"));
button7.setOnClickListener(new Click("7"));
button8.setOnClickListener(new Click("8"));
button9.setOnClickListener(new Click("9"));
button_xing.setOnClickListener(new Click("*"));
button_jing.setOnClickListener(new Click("#"));
button_clear.setOnClickListener(new Clear());
button_delete.setOnClickListener(new Delete());
//查找拨号控件
Button button_call = (Button) findViewById(R.id.button_call);
//给控件一个点击事件监听
button_call.setOnClickListener(new Call());
}
private class Delete implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String s1 = edit_text.getText().toString().trim();
String s2 = s1.substring(0, s1.length()-1);
//Toast.makeText(MainActivity.this, s2, Toast.LENGTH_SHORT).show();
edit_text.setText(s2);
}
}
private class Clear implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
edit_text.setText("");
}
}
private class Click implements OnClickListener{
String str;
public Click(String s){
str=s;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//Toast.makeText(MainActivity.this, str, Toast.LENGTH_SHORT).show();
edit_text.setText(edit_text.getText().toString().trim()+str);
}
}
private class Call implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//创建意图
Intent intent=new Intent();
//设置动作,拨打的动作
intent.setAction(Intent.ACTION_CALL);
String text = edit_text.getText().toString().trim();
//设置数据
intent.setData(Uri.parse("tel://"+text));
startActivity(intent);
}
}
}
7.常见布局有五种
a.线性布局 LinearLayout水平线horizontal和竖直线vertical
b.相对布局 RelativeLayout选定一个参照物通过android:layout_toRightOf等树形来控制布局
c.绝对布局 AbsoluteLayout相对于左上角的坐标位置,左上角为0点 向下为Y+ 向右为X+
d.表格布局 TableLayout它是LinearLayout的子类,一般开发直接用线性布局
e.帧布局 FrameLayout帧布局相当于一块画布,内容是一层一层堆叠上去的.
1G是模拟信号,通话质量差;2G能满足基本的通话;2.5G又叫GPRS,有低速上网服务;2.75G又叫EDGE,上网速度比GPRS稍快
3G上网可达300KB/S,3G中又有几个引申的3.5G 3.75G 上网速度越来越快.可达到42M/s,到了4G时代,网速更是快的不行
然而流量费的高价也是不容忽视的;华为已经自主研发并获取了5G的专利.
2.安卓的体系结构主要分为四大部分.a.应用层(application) b.应用程序框架层(application framework)
c.核心代码库(libraries) 这部分是由C或者C++编写的源代码 d.Linux kernel 这个是Linux的内核,驱动硬件.
举个例子:一个闹钟的应用程序,在我设定了闹钟以后, 在到点以后,应用程序会调用框架层的notification framework(通知)
,再由通知框架调用media相关的核心代码,再由核心代码调用audio Driver 驱动喇叭发出声音完成响铃的效果.
3.JVM是java virtual machine 的简称,java代码运行时先要将.java文件编译成.class字节码文件,然后再运行
而Dalvik VM则是安卓的虚拟机,它会一次性将所有的代码编译为dex文件,在效率上比JVM快,其次DVM是google研发的,JVM是SUN公司研发的
后被甲骨文收购.在android4.4以后多了一个ART模式,采用ART模式时,安装软件是会将软件进行预编译,这样大大提高了软件的运行速度.
在硬件上,JVM基于栈内存,而DVM基于寄存器,基于寄存器的虚拟机对于运行变异后更大的程序来说,运行速度更快.
4.Android工程的目录结构,主要需要着重记忆的是四个位置,记88个字(父母之命媒妁之言)
a.gen文件夹里的R文件 这个相当于媒人,里面存储了一些对象的id,在关心控件时getViewById(id)
b.项目根目录下的AndroidManifest.xml文件 相当于父母, 里面可以配置项目的权限(目前只用到这些)
c.layout(res-drawable下) 妹子 布局文件,显示给人看的
d.src下的mainAcitvity.java文件 汉子 业务逻辑都写在这个文件里
关系:R文件联系layout文件和mainActivity文件,由manifest.xml文件提供权限
5.安卓项目的开发流程:
a.首先写布局文件,创建布局文件;
b.在java文件中写好业务逻辑, View v= findViewById()得到关心控件;
c.关联好时间,一般为点击事件 通过关心控件v.setOnclickListener() 设置点击监听
参数需要一个OnClickListener的子类对象(对象自动调用其onclick方法)
在这里我们采用的方法是写一个内部类实现了OnclickListener接口,复写其onclick方法,完成一些逻辑代码.
d.最后需要在xml文件中给项目添加对应的权限,否则程序点击后会报错.
6.拨号器的完成
a.完成布局文件
根据拨号器的按先在画图工具里完成大概的布局,有了思路以后可以发现整体是一个竖直方向的线性布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button1"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="1"
/>
<Button
android:id="@+id/button2"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="2"
/>
<Button
android:id="@+id/button3"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="3"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button4"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="4"
/>
<Button
android:id="@+id/button5"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="5"
/>
<Button
android:id="@+id/button6"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="6"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button7"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="7"
/>
<Button
android:id="@+id/button8"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="8"
/>
<Button
android:id="@+id/button9"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="9"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/button_xing"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="*"
/>
<Button
android:id="@+id/button0"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="0"
/>
<Button
android:id="@+id/button_jing"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text="#"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="2">
<Button
android:id="@+id/button_call"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_below="@id/button0"
android:text="拨号" />
<Button
android:id="@+id/button_clear"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_toLeftOf="@id/button_call"
android:text="清空" />
<Button
android:id="@+id/button_delete"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/button_call"
android:text="删除" />
</RelativeLayout>
</LinearLayout>
b.业务逻辑
在写内部类的时候要在onclick方法中创建一个意图Intent intent=new Intent(),通过对意图设置动作
intent.setAction(Intent.ACTION_CALL) 参数是Intent类里的静态常量 设置万动作以后还要设置数据
intent.setData(Uri.parse("tel://110")) 参数是统一资源标识符 uri 将电话号码经过转换后可以添加进去
另外的重点就是Edit_Text对象的setText()方法,参数为String getText().toString().trim()得到去重的字符串
package com.heima.call;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.text.Editable;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
static EditText edit_text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.show);
//查找EditText控件
edit_text = (EditText) findViewById(R.id.edit_text);
//创建其他按钮点击
//首先获取按钮控件
/*for (i = 1; i < 10; i++) {
button = (Button) findViewById(0x7f080000+i);
//绑定点击事件监听
}*/
Button button0=(Button) findViewById(R.id.button0);
Button button1=(Button) findViewById(R.id.button1);
Button button2=(Button) findViewById(R.id.button2);
Button button3=(Button) findViewById(R.id.button3);
Button button4=(Button) findViewById(R.id.button4);
Button button5=(Button) findViewById(R.id.button5);
Button button6=(Button) findViewById(R.id.button6);
Button button7=(Button) findViewById(R.id.button7);
Button button8=(Button) findViewById(R.id.button8);
Button button9=(Button) findViewById(R.id.button9);
Button button_xing=(Button) findViewById(R.id.button_xing);
Button button_jing=(Button) findViewById(R.id.button_jing);
Button button_clear=(Button) findViewById(R.id.button_clear);
Button button_delete=(Button) findViewById(R.id.button_delete);
button0.setOnClickListener(new Click("0"));
button1.setOnClickListener(new Click("1"));
button2.setOnClickListener(new Click("2"));
button3.setOnClickListener(new Click("3"));
button4.setOnClickListener(new Click("4"));
button5.setOnClickListener(new Click("5"));
button6.setOnClickListener(new Click("6"));
button7.setOnClickListener(new Click("7"));
button8.setOnClickListener(new Click("8"));
button9.setOnClickListener(new Click("9"));
button_xing.setOnClickListener(new Click("*"));
button_jing.setOnClickListener(new Click("#"));
button_clear.setOnClickListener(new Clear());
button_delete.setOnClickListener(new Delete());
//查找拨号控件
Button button_call = (Button) findViewById(R.id.button_call);
//给控件一个点击事件监听
button_call.setOnClickListener(new Call());
}
private class Delete implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String s1 = edit_text.getText().toString().trim();
String s2 = s1.substring(0, s1.length()-1);
//Toast.makeText(MainActivity.this, s2, Toast.LENGTH_SHORT).show();
edit_text.setText(s2);
}
}
private class Clear implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
edit_text.setText("");
}
}
private class Click implements OnClickListener{
String str;
public Click(String s){
str=s;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//Toast.makeText(MainActivity.this, str, Toast.LENGTH_SHORT).show();
edit_text.setText(edit_text.getText().toString().trim()+str);
}
}
private class Call implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//创建意图
Intent intent=new Intent();
//设置动作,拨打的动作
intent.setAction(Intent.ACTION_CALL);
String text = edit_text.getText().toString().trim();
//设置数据
intent.setData(Uri.parse("tel://"+text));
startActivity(intent);
}
}
}
7.常见布局有五种
a.线性布局 LinearLayout水平线horizontal和竖直线vertical
b.相对布局 RelativeLayout选定一个参照物通过android:layout_toRightOf等树形来控制布局
c.绝对布局 AbsoluteLayout相对于左上角的坐标位置,左上角为0点 向下为Y+ 向右为X+
d.表格布局 TableLayout它是LinearLayout的子类,一般开发直接用线性布局
e.帧布局 FrameLayout帧布局相当于一块画布,内容是一层一层堆叠上去的.
0 0
- day01总结
- day01总结
- day01总结
- day01总结
- day01-day03的总结
- JavaScript总结day01
- H5总结(day01)
- day01
- day01
- DAY01
- DAY01
- day01
- Day01
- day01
- day01
- day01
- day01
- day01
- ORACLE多表关联UPDATE 语句
- 字母图形
- ffmpeg-nvenc
- 队列的链表实现
- syscall error number : errno
- day01总结
- [linux] c 实现简单的web服务器
- 【框架基础】:Java反射机制详解(一)
- 电影《肖申克的救赎》给你最深的感受是什么?
- Oracle数据库视图
- Jquery Datatables 1.10兼容1.9 的错误解决
- mvp
- Netfilter CONNMARK用法及分析(二)-- 内核代码分析
- Python入门——列表生成器基础