1.Android是什么
手机设备的软件栈,包括一个完整的操作系统、中间件、关键的应用程序,底层是linux内核,安全管理、内存管理、进程管理、电源管理、硬件驱动 2.Dalvik VM 和 JVM 的比较

3.常见adb指令
platform-tools/adb.exe
adb.exe : android debug bridge android调试桥
adb devices:列出所以连接的设备
adb kill-server :杀死adb调试桥
adb start-server :启动adb调试桥
adb install xxx.apk 如果有多个设备,我们可以指定设备 adb install –s emulator-5554 D:/xxx.apk
adb uninstall 包名 : 卸载应用
adb pull 源文件 目标文件 : 导出文件
adb push 源文件 目标文件 : 导入文件 4.Android应用程序架构

5.程序打包&安装的过程

6.电话拨号器
代码提示键:Alt+/
出现黄色的解决方式:Ctrl+1
<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=".PhoneActivity" > <EditText
android:id="@+id/et_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
/>
<Button
android:id="@+id/bt_dail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/et_number"
android:text="@string/dail" /> </RelativeLayout> package com.example.demo1; import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast; public class PhoneActivity extends Activity implements OnClickListener { private EditText dt_number = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_phone);
Button bt_dail = (Button)this.findViewById(R.id.bt_dail);
dt_number = (EditText)this.findViewById(R.id.et_number);
bt_dail.setOnClickListener(this); } public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_dail:
String number = dt_number.getText().toString().trim();
if (TextUtils.isEmpty(number)) {
Toast.makeText(PhoneActivity.this, "号码不能为空!",
Toast.LENGTH_SHORT).show();
return;
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);
break;
default:
break;
} }
} <activity
android:name="com.example.demo1.PhoneActivity"
android:label="@string/title_activity_phone" >
<!--决定启动哪个activity-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.CALL_PHONE" /> 7.点击事件的4种写法
(1).创建一个内部类定义点击事件
bt_dail.setOnClickListener(new MyListener());
private class MyListener implements OnClickListener
(2).采用匿名内部类创建点击事件
bt_dail.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
// TODO Auto-generated method stub }
});
(3).让类实现点击事件的接口,(常用)
public class PhoneActivity extends Activity implements OnClickListener
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_dail:
default:
break;
}
(4).在布局文件中绑定一个点击(android:onClick="")
android:onClick="dail"
public void dail(View view) {} 8.短信发送器
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <EditText
android:id="@+id/et_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入电话号码" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/et_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入内容"
android:lines="5" />
<Button
android:id="@+id/bt_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="发送" />
</LinearLayout> package com.example.demo1; import java.util.ArrayList; import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast; public class SMSActivity extends Activity { private EditText mEditTextNumber = null;
private EditText mEditTextContent = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sms);
Button mButtonSend = (Button) this.findViewById(R.id.bt_send);
this.mEditTextNumber = (EditText) this.findViewById(R.id.et_number);
this.mEditTextContent = (EditText) this.findViewById(R.id.et_content);
mButtonSend.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String number = mEditTextNumber.getText().toString().trim();
String content = mEditTextContent.getText().toString().trim();
if (TextUtils.isEmpty(number) || TextUtils.isEmpty(content)) {
Toast.makeText(SMSActivity.this, "电话号码或内容不能为空!", 0).show();
} else {
PendingIntent sentIntent = PendingIntent.getBroadcast(SMSActivity.this, 0, new Intent(), 0);
SmsManager smsManager = SmsManager.getDefault(); //如果字数超过70,需拆分成多条短信发送
ArrayList<String> contents = smsManager.divideMessage(content);
for (String str : contents) {
//最后二个参数为短信已发送的广播意图,最后一个参数为短信对方已收到短信的广播意图
smsManager.sendTextMessage(number, null, str, sentIntent,null);
}
Toast.makeText(SMSActivity.this, "短信发送完成", Toast.LENGTH_LONG).show(); }
}
});
} } <uses-permission android:name="android.permission.SEND_SMS"/> 9. Android 中各种布局
<!-- LinearLayout - 线形布局。
orientation - 容器内元素的排列方式。vertical: 子元素们垂直排列;horizontal: 子元素们水平排列
gravity - 内容的排列形式。常用的有 top, bottom, left, right, center 等,详见文档 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
android:orientation="vertical" > <!-- FrameLayout - 层叠式布局。以左上角为起点,将 FrameLayout 内的元素一层覆盖一层地显示 --> <FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FrameLayout" >
</TextView> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Frame Layout" >
</TextView>
</FrameLayout>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/hello_world" />
<!--
TableLayout - 表格式布局。
TableRow - 表格内的行,行内每一个元素算作一列
collapseColumns - 设置 TableLayout 内的 TableRow 中需要隐藏的列的列索引,多个用“,”隔开
stretchColumns - 设置 TableLayout 内的 TableRow 中需要拉伸(该列会拉伸到所有可用空间)的列的列索引,多个用“,”隔开
shrinkColumns - 设置 TableLayout 内的 TableRow 中需要收缩(为了使其他列不会被挤到屏幕外,此列会自动收缩)的列的列索引,多个用“,”隔开
-->
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:collapseColumns="1">
<TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:text="行1列1" />
<TextView android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:text="行1列2" />
<TextView android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:text="行1列3" />
</TableRow>
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="行2列1" />
</TableRow>
</TableLayout>
<!--
AbsoluteLayout - 绝对定位布局。
layout_x - x 坐标。以左上角为顶点
layout_y - y 坐标。以左上角为顶点
-->
<AbsoluteLayout android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="AbsoluteLayout"
android:layout_x="100px"
android:layout_y="100px" />
</AbsoluteLayout> <!--
RelativeLayout - 相对定位布局。
layout_centerInParent - 将当前元素放置到其容器内的水平方向和垂直方向的中央位置(类似的属性有 :layout_centerHorizontal, layout_alignParentLeft 等)
layout_marginLeft - 设置当前元素相对于其容器的左侧边缘的距离
layout_below - 放置当前元素到指定的元素的下面
layout_alignRight - 当前元素与指定的元素右对齐
-->
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:layout_width="wrap_content" android:id="@+id/abc"
android:layout_height="wrap_content" android:text="centerInParent=true"
android:layout_centerInParent="true" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="marginLeft=20dp"
android:layout_marginLeft="20dp" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="xxx"
android:layout_below="@id/abc" android:layout_alignRight="@id/abc" />
</RelativeLayout>
</LinearLayout>

无废话Android之常见adb指令、电话拨号器、点击事件的4种写法、短信发送器、Android 中各种布局(1)的更多相关文章

  1. Android journey3 @点击事件的4种写法

    对于android布局中的控件,如Button等会有相应的点击事件去响应它所需要的功能,今天我们就以电话拨号器的代码说明下几种点击事件: package com.itheima.phone; impo ...

  2. Android笔记---点击事件的四种写法

    Android 点击事件的四种写法: 1. 以内部类的形式实现 OnClickListener 接口.定义点击事件 class MainActivity extents Activity{ // .. ...

  3. Android中点击事件的四种写法详解

    Android中点击事件的四种写法 使用内部类实现点击事件 使用匿名内部类实现点击事件 让MainActivity实现View.OnClickListener接口 通过布局文件中控件的属性 第一种方法 ...

  4. [Android] 点击事件的四种写法

    点击事件的必备条件:实现OnClickListener接口,重写onclick(View v)方法 以拨号简单案例为例,如下图效果: 逻辑流程: 获取点击对象,获取数据 给对象设置监听类 实现OnCl ...

  5. [Android]Java中点击事件的四种写法

    点击事件的必备条件:实现OnClickListener接口,重写onclick(View v)方法 以拨号简单案例为例,如下图效果: 逻辑流程: 获取点击对象,获取数据 给对象设置监听类 实现OnCl ...

  6. 【转】Android - Button(按钮)的响应点击事件的4种写法

    原文网址:http://www.yrom.net/blog/2011/12/12/android-4-onclicklistener-of-button/ Button控件setOnclickList ...

  7. android中点击事件的4种写法

    android中获取到一些控件(比如说按钮)时,一般会为其添加点击事件,android中的点击事件一共有4中写法. 假设在布局文件中声明如下 ....... <Button android:la ...

  8. Android - Button(按钮)的响应点击事件的4种写法

    Button控件setOnclickListener(View.OnClickListener listener)来接收一个点击事件的监听器 自定义一个点击事件监听器类让其实现View.OnClick ...

  9. Android代码学习--点击事件的几种写法

    由来:常规的写法参见<写一个apk>,每次点击按钮,按钮先查找文本框等元素,然后再操作,其实查找操作是很费时的操作,因此将该定义放到Activity的onCreate中:Oncreate只 ...

随机推荐

  1. IDEA 新建文件默认加入CVS

    是要先add,不过可以设置创建的文件都默认 add的.修改默认值看下图:打开系统设置,找到 Version Control 设置选项: 在 When files are created 选项中选择第二 ...

  2. 【GoLang】与或非 异或操作

    在Go规范,^这个运算符在一元运算符和二元运算符中都出现了.那么他们分别是啥?在规范中说道:^ bitwise XOR integers这是按位异或. Go语言位操作实例 <!-- lang: ...

  3. 如何准确高效的获取数据库新插入数据的主键id

    例如我们新建了一张表UserInformation,字段如下Id,为主键,自增,其它字段Name,Pwd,Email 然后我们来执行一个新增插入操作: insert into UserInformat ...

  4. jq隐藏页面的一行

    <script type="text/javascript" src="http://files.cnblogs.com/914556495wxkj/jquery- ...

  5. 【转】.so兼容32位和64位

    本文转自:http://blog.csdn.net/fwt336/article/details/51700300 安卓的兼容性是一个很令人头疼的问题,这几天又遇到了,还好还是解决了. 我遇到的问题是 ...

  6. 在linux环境编译boost

    1.在boost官网:http://www.boost.org/下载相应版本的boost 2.解压boost到相应目录,在boost跟目录下有b2可执行程序,可以通过输入命令“/b2 --help”, ...

  7. 算法手记 之 数据结构(并查集详解)(POJ1703)

    <ACM/ICPC算法训练教程>读书笔记-这一次补上并查集的部分.将对并查集的思想进行详细阐述,并附上本人AC掉POJ1703的Code. 在一些有N个元素的集合应用问题中,通常会将每个元 ...

  8. java 入门 第二季1

    (1). 类和对象(java 语言是面向对象的) 1). 类是对象的类型 具有相同的属性和方法的一组对象的集合 类:属性和方法 定义类: 类名 属性 方法 //class为关键字 2.定义类时,首字母 ...

  9. Match:Seek the Name, Seek the Fame(POJ 2752)

    追名逐利 题目大意:给定一个字符串S,要你找到S的所有前缀后缀数组 还是Kmp的Next数组的简单应用,但是这一题有一个BUG,那就是必须输出字符串的长度(不输出就WA),然而事实上对于abcbab, ...

  10. JS 异步加载的方法

    (1) defer,只支持IE : <script type="text/javascript" defer="defer"> </scrip ...