文章标题
来源:互联网 发布:c语言for是什么意思 编辑:程序博客网 时间:2024/06/05 08:32
package com.example.day01_1;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.Toast;public class MainActivity extends Activity{ private Button call=null; private Button mesage=null; private Button jishiqi=null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); call=(Button)findViewById(R.id.button1); mesage=(Button)findViewById(R.id.button2); jishiqi=(Button)findViewById(R.id.button3); call.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO 自动生成的方法存根 Uri s=Uri.parse("tel:123456789"); Intent intent=new Intent(Intent.ACTION_CALL,s); startActivity(intent); }}); mesage.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO 自动生成的方法存根 //第一种 Uri s=Uri.parse("sms:123456789"); Intent intent=new Intent(Intent.ACTION_SENDTO,s); intent.putExtra("sms_body", "你好!"); startActivity(intent); //第二种// Intent intent=new Intent();// intent.setAction(Intent.ACTION_SENDTO);// intent.setData(Uri.parse("sms:5554"));// intent.putExtra("sms_body", "how are you...");// startActivity(intent); }}); jishiqi.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO 自动生成的方法存根 try{ //这儿老调取不成功第三方,谁知道可以回复我。谢谢 Intent intent=new Intent(); intent.setClassName("com.tencent.qq", "com.tencent.qq."); startActivity(intent); } catch(Exception e){ System.out.println(e); Toast.makeText(MainActivity.this, "没有找到对应的程序", Toast.LENGTH_SHORT).show(); } }}); }}
界面布局
<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="com.example.day01_1.MainActivity" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginLeft="24dp" android:layout_marginTop="90dp" android:text="@string/call" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/button1" android:layout_alignBottom="@+id/button1" android:layout_alignParentRight="true" android:layout_marginRight="54dp" android:text="@string/mesage" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button1" android:layout_marginTop="94dp" android:layout_toRightOf="@+id/button1" android:text="@string/jishiqi" /></RelativeLayout>
字符串声明
<?xml version="1.0" encoding="utf-8"?><resources> <string name="app_name">day01-1</string> <string name="hello_world">Hello world!</string> <string name="action_settings">Settings</string> <string name="mesage">发信息</string> <string name="call">打电话</string> <string name="jishiqi">qq</string></resources>
//注册权限
<uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.SEND_SMS"/>
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- SDUT-2862 勾股定理
- linux vim 置配
- struts2学习笔记之十三(表单标签和非表单标签)
- 流与文件:NIO.2的介绍和使用
- 第三章124页40题
- 文章标题
- Android源代码结构分析
- Apache axis2+Eclipse+Web service 安装部署经验总结
- 测试理论:一种改善测试业务积累和工作量评估的方法
- P124.46(计算Fibonacci数.)
- maya开洞的几种方法总结之二
- Cocos2d-x背景音乐和音效
- 【转】关于STM32外接4—16MHz晶振主频处理方法
- codeforces 543d Road Improvement 树形dp