多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 互聯網 > Android-2電話應用,短信應用

Android-2電話應用,短信應用

來源:程序員人生   發布時間:2014-11-13 09:03:58 閱讀次數:2659次

Activity的生命周期

 
Android的核心組件 1.Viiew :界面 ,組織UI控件 2.Intent :意圖,支持組件之間的通訊 3.Activity:處理界面與UI互動 4.Content Provider:存儲同享數據 5.IntentReceiver:接收信息及時間處理 6.Service:后臺服務(如硬件與驅動的服務 ) 7.Notification:消息與通訊 Android的運行 AndroidManifest.xml為程序的入口


R.文件是我們創建的1個目錄文件


------------------------------------------------------------------
建立打電話發短信的利用程序

1.對number對話框定義
<EditText
        android:id="@+id/NummberText" ----->在R文件中配置ID地址
        android:layout_width="match_parent" ------>充滿布局文件
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" ------>頂部對齊
        android:layout_centerHorizontal="true" ----->居中
        android:textColor="#FF0099" --------->設置文字的字體
        android:ems="10"
  android:hint="@string/SMS_please"
        android:inputType="phone" > ------->默許的陰影提示
        <requestFocus />
    </EditText>
2.按鈕的設計
<Button
        android:id="@+id/Call_otherButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/NummberText" --->相對布局
        android:textColor="#9900CC"------>設置文字的字體色彩
        android:layout_centerHorizontal="true"
        android:text="@string/call_other" />

    <Button
        android:id="@+id/Call_xiaoyuButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Call_otherButton"
        android:textColor="#FF0033"
        android:layout_centerHorizontal="true"
        android:text="@string/love_xiaoyu" />

    <Button
        android:id="@+id/Call_mangqi"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Call_xiaoyuButton"
        android:layout_centerHorizontal="true"
        android:text="@string/call_wangqi" />

3.設置小 layout
 <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Call_mangqi"
        android:layout_below="@+id/Call_mangqi"
        android:textColor="#FF9595"
        android:text="@string/Talk_Message" />
------>@String在value文件中加載strings并在其中加載Talk_Message字符串


5.制作文本框



<EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:lines="8" --->設置函數的大小
        android:hint="@string/_love"  -->設計默許值得大小
        android:ems="10"
        android:inputType="textMultiLine" />

6邏輯設計
public class MainActivity extends Activity implements OnClickListener{
 Button Call_other;
 Button Call_wangqi;
 Button Call_xiaoyu;
 Button Send_other;
 Button Send_wangqi;
 Button Send_xiaoyu;
 EditText Nummber_edit;
 EditText Talk_Edit;
 @Override
A-定義控件便于尋覓
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Nummber_edit = (EditText)B-findViewById(R.id.NummberText); 通過findViewById來找到控制控件
  Talk_Edit= (EditText)findViewById(R.id.editText1);
  Call_other = (Button)findViewById(R.id.Call_otherButton);
  Call_wangqi= (Button)findViewById(R.id.Call_mangqi);;
  Call_xiaoyu= (Button)findViewById(R.id.Call_xiaoyuButton);;
  Send_other= (Button)findViewById(R.id.Send_friend);
  Send_wangqi= (Button)findViewById(R.id.Send_wangqi);
  Send_xiaoyu= (Button)findViewById(R.id.Send_xiaoyu);

C -public class MainActivity extends Activity implements OnClickListener{
將主類實現OnClickListener接口可以對控件通過1個OnClick控制

D:1.在文件中設計按鈕的事件
private void MyCallOther(){
  String num = Nummber_edit.getText().toString();
  if(TextUtils.isEmpty(num)){ ---判斷字符中的文字是不是為空
   Toast.makeText(MainActivity.this, "電話為空了>.<"0 --顯示的時間).show();--土司生成
   return ;
  }else{
   Intent intent = new Intent();----打電話的程序重要的1點事必須啟動1個Intent的程序
   Toast.makeText(MainActivity.this, "電話打向"+num, 0).show();--必須show出來
   intent.setAction(Intent.ACTION_CALL);---設置打電話的設置
   intent.setData(Uri.parse("tel:"+num));---設置電環號碼
   startActivity(intent);---啟動事件
   return;
  }
 }
 private void MyCallxiaoyu(){
  Intent intent = new Intent();
  Toast.makeText(MainActivity.this, "Love曉宇691526", 0).show();
  intent.setAction(Intent.ACTION_CALL);
  intent.setData(Uri.parse("tel:"+"691526"));
  startActivity(intent);
  return ;
 }
 private void CallWangqi (){
   Intent intent = new Intent();
   Toast.makeText(MainActivity.this, "打給討厭鬼王琪>.<", 0).show();
   intent.setAction(Intent.ACTION_CALL);
   intent.setData(Uri.parse("tel:"+"652008"));
   startActivity(intent);
 }

<EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:lines="8" --->設置函數的大小
        android:hint="@string/_love"  -->設計默許值得大小
        android:ems="10"
        android:inputType="textMultiLine" />

6邏輯設計
public class MainActivity extends Activity implements OnClickListener{
 Button Call_other;
 Button Call_wangqi;
 Button Call_xiaoyu;
 Button Send_other;
 Button Send_wangqi;
 Button Send_xiaoyu;
 EditText Nummber_edit;
 EditText Talk_Edit;
 @Override
A-定義控件便于尋覓
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Nummber_edit = (EditText)B-findViewById(R.id.NummberText); 通過findViewById來找到控制控件
  Talk_Edit= (EditText)findViewById(R.id.editText1);
  Call_other = (Button)findViewById(R.id.Call_otherButton);
  Call_wangqi= (Button)findViewById(R.id.Call_mangqi);;
  Call_xiaoyu= (Button)findViewById(R.id.Call_xiaoyuButton);;
  Send_other= (Button)findViewById(R.id.Send_friend);
  Send_wangqi= (Button)findViewById(R.id.Send_wangqi);
  Send_xiaoyu= (Button)findViewById(R.id.Send_xiaoyu);

C -public class MainActivity extends Activity implements OnClickListener{
將主類實現OnClickListener接口可以對控件通過1個OnClick控制

D:1.在文件中設計按鈕的事件
private void MyCallOther(){
  String num = Nummber_edit.getText().toString();
  if(TextUtils.isEmpty(num)){ ---判斷字符中的文字是不是為空
   Toast.makeText(MainActivity.this, "電話為空了>.<"0 --顯示的時間).show();--土司生成
   return ;
  }else{
   Intent intent = new Intent();----打電話的程序重要的1點事必須啟動1個Intent的程序
   Toast.makeText(MainActivity.this, "電話打向"+num, 0).show();--必須show出來
   intent.setAction(Intent.ACTION_CALL);---設置打電話的設置
   intent.setData(Uri.parse("tel:"+num));---設置電環號碼
   startActivity(intent);---啟動事件
   return;
  }
 }
 private void MyCallxiaoyu(){
  Intent intent = new Intent();
  Toast.makeText(MainActivity.this, "Love曉宇691526", 0).show();
  intent.setAction(Intent.ACTION_CALL);
  intent.setData(Uri.parse("tel:"+"691526"));
  startActivity(intent);
  return ;
 }
 private void CallWangqi (){
   Intent intent = new Intent();
   Toast.makeText(MainActivity.this, "打給討厭鬼王琪>.<", 0).show();
   intent.setAction(Intent.ACTION_CALL);
   intent.setData(Uri.parse("tel:"+"652008"));
   startActivity(intent);
 }

E:設置發短信的事件
private void SendFriend(){
  String number = Nummber_edit.getText().toString();
  String sms = Talk_Edit.getText().toString();
  if(TextUtils.isEmpty(number)||TextUtils.isEmpty(sms)){---設置發短信的電話號碼和控件
   Toast.makeText(MainActivity.this, "信息為空了>.<", 0).show();
   return ;
  }else{
   Toast.makeText(MainActivity.this, "信息發向了"+number, 0).show();
   SmsManager message = SmsManager.getDefault();
   message.sendTextMessage(number--電話, null--發信者, sms--內容, null,null);---發短信
   Toast.makeText(MainActivity.this, "信息發送成功>.
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 成人国产欧美精品一区二区 | 国产精品欧美视频另类专区 | 亚洲欧美日本综合 | 性大交 | www.自拍| 在线免费欧美 | japanese日本护士xxxx18一19 | 加勒比一本大道香蕉在线视频 | 手机在线免费视频 | 欧美日本一区二区三区道 | japan18hdxxxx欧美 japanbabes日本护士18免费 | 色xxxx| 欧美黄色免费 | 亚洲国产成人资源在线桃色 | 国产精品v在线播放观看 | 男女羞羞视频网站 | 看性过程三级视频在线观看 | 国产α片 | 欧美亚洲综合在线观看 | 最新亚洲精品 | 在线观看欧洲成人免费视频 | 亚洲国产精品久久久久久 | 最近更新中文字幕免费版 | 福利视频一区二区微拍堂 | 天堂在线v| h网站在线看 | 自拍中文字幕 | 图片区小说欧洲区 | 拍拍拍免费高清在线观看视频 | 在线欧美一区 | 天天天狠天天透天天制色 | 久久国产精品免费 | 五月免费视频 | 日韩高清一级 | 国产精品久久久久久搜索 | 久久免费精品一区二区 | 一二三四视频免费观看在线看 | 一区二区三区亚洲 | 二级毛片在线观看 | 网友自拍区一区二区三区 | 最新中文字幕免费视频 |