Android实例demo3之Button按钮的多种响应方法,打电话
来源:互联网 发布:贺卫方 知乎 编辑:程序博客网 时间:2024/06/06 18:55
实现拨打电话功能要首先实现添加拨打电话的权限:
<uses-permission android:name="android.permission.CALL_PHONE"/>
<TextView
android:id="@+id/calltext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/call_text"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:layout_below="@id/calltext"
android:id="@+id/calledit"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/call_button1"
android:id="@+id/button1"
android:layout_below="@id/calledit"
android:onClick="callphone"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/call_button2"
android:id="@+id/button2"
android:layout_toRightOf="@id/button1"
android:layout_below="@id/calledit"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/call_button3"
android:id="@+id/button3"
android:layout_below="@id/button2"
android:layout_marginLeft="50dp"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/call_button4"
android:id="@+id/button4"
android:layout_below="@id/button3"
android:layout_alignLeft="@id/button3"
/>
(1)匿名内部类实现响应
mbutton2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
});
(2)类实现接口
public class Button3 extends Activity implements OnClickListener
mbutton2.setOnClickListener(this);
@Override
public void onClick(View arg0) {
}
(3)接口实现
// mbutton2.setOnClickListener(new Buttonclicklisten());
Buttonclicklisten mbuttonaction = new Buttonclicklisten();
mbutton2.setOnClickListener(mbuttonaction);
public class Buttonclicklisten implements OnClickListener{
@Override
public void onClick(View arg0) {
}
}
(4)xml定义响应方法
public void callphone(View v) {
}
(5)拨打电话方法
Intent mintent = new Intent();
mintent.setAction(Intent.ACTION_CALL);
mintent.setData(Uri.parse("tel:"+mnumber));
startActivity(mintent);
- Android实例demo3之Button按钮的多种响应方法,打电话
- android 用户界面笔记之Button和ImageButton实现按钮响应事件两种方法
- Android之Button按钮点击事件的三种方法
- Android实例demo5之FileOutputStream文件写入的多种方法
- button的多种监听方法
- android用户界面之按钮(Button)教程实例汇
- android用户界面之按钮(Button)教程实例汇
- android用户界面之按钮(Button)教程实例汇
- android用户界面之按钮(Button)教程实例汇
- android button的两种响应点击的方法
- Android Button 的单击事件的三种响应方法
- Android Button 的单击事件的三种响应方法
- Android复习之按钮button
- Android Button响应点击事件的几种方法大合集
- Android点击按钮打电话
- Android - Button(按钮)的响应点击事件的4种写法
- Android中同一个button按钮每次点击响应不同的事件
- Android学习笔记——Button(按钮)响应事件的四种方式
- Hadoop实战-中高级部分 之 Hadoop MapReduce工作原理
- web攻防之Cookie注入
- jquery弹出层的显示特效和消除特效
- notepad++安装markdown插件
- switch(整数表达式/枚举常量)
- Android实例demo3之Button按钮的多种响应方法,打电话
- MySQL数据库的环境及简单操作
- xcode6提交应用失败(Error Description not available)
- 走进 WatchKit Framework
- 对Spring MVC初学的认识
- STM32.定时器
- 指针初始化是非常重要的,当我们在声明一个指针的时候请记得给它赋初值NULL,free释放完指针内容的时候也给他赋null初值。谢谢
- Google官方对Andoird 2.x提供的ActionBar支持
- iPhone安装企业软件到75%提醒“当前无法完成安装”