日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

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

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

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

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, "信息發送成功>.
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 精品视频久久 | 欧美日韩精品电影 | 成人免费视频在线观看 | 国产传媒在线播放 | 色婷婷综合久久久 | 很很鲁在线视频播放影院 | 国产做爰全过程免费的视频 | 一区二区精品在线 | 一区二区三区四区在线 | 久久久成人av | 国产精品一区二区三区在线 | 国产精品久久久久久吹潮 | 中文字幕av一区二区三区 | 亚洲免费二区 | 在线天堂网 | 在线视频91 | 久久99精品久久久久久琪琪 | 成人欧美一区二区三区黑人动态图 | 中文字幕人成乱码在线观看 | 在线视频 亚洲 | 亚洲精品乱码久久久久久蜜桃不爽 | 成人在线免费网站 | 日日夜夜狠狠干 | 国产第一页在线 | 7777久久香蕉成人影院 | 99久久精品免费 | 一区二区在线视频 | 成人国产在线 | 日日干天天射 | 国产精品国产三级国产a | 日本在线观看一区 | 在线一区二区三区 | 福利一区二区 | 精品在线一区 | 色久视频 | 国产成年人免费视频 | 舐め犯し波多野结衣在线观看 | 亚洲视频免费观看 | 中文字幕av一区二区 | 久久免费看 | 精品国产成人 |