环境

eclipse
Win10
链接(配置好的)
链接:https://pan.baidu.com/s/16HhriLgS_BX5zJRkLL4w2A
提取码:7ziq
复制这段内容后打开百度网盘手机App,操作更方便哦

下载SDK

创建虚拟Android设备


点new新建即可。

创建项目

file–>New–>Android application project

选择的版本应与虚拟设备对应

next

可以选择更换图标 或者next默认

选择activity的样式,第一个默认即可。

finish

开启虚拟机

直接右键运行下这个hello world看看存不存在版本问题:

没有问题的话接下来就可以开始搞各种事情了

添加按钮

  • 拖拽形式添加
  • 代码形式添加
    <Button android:id="@+id/btn_ok"android:layout_width="wrap_content"android:layout_height="wrap_content"  //按内容的实际大小来衡量android:layout_below="@+id/hello"     //在hello文本框下面android:text="ok"/>

制作一个简单的拨号器

布局文件
    <TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="19sp"android:textColor="#ff0000"android:text="请输入电话号码" /> /><EditTextandroid:id="@+id/ed_number"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/textView1"android:hint="电话号码"/><Button android:id="@+id/btn_1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/ed_number" android:text="1"/><Button android:id="@+id/btn_2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/ed_number" android:layout_toRightOf="@+id/btn_1"android:text="2"/><Button android:id="@+id/btn_3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/ed_number" android:layout_toRightOf="@+id/btn_2"android:text="3"/><Button android:id="@+id/btn_4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_1" android:text="4"/><Button android:id="@+id/btn_5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_2" android:layout_toRightOf="@+id/btn_4"android:text="5"/><Button android:id="@+id/btn_6"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_3" android:layout_toRightOf="@+id/btn_5"android:text="6"/><Button android:id="@+id/btn_7"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_4" android:text="7"/><Button android:id="@+id/btn_8"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_5" android:layout_toRightOf="@+id/btn_7"android:text="8"/><Button android:id="@+id/btn_9"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_6" android:layout_toRightOf="@+id/btn_8"android:text="9"/><Button android:id="@+id/btn_0"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_8" android:text="0"/><Buttonandroid:id="@+id/btn_call"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignRight="@+id/ed_number"android:layout_below="@+id/btn_9"android:layout_marginRight="18dp"android:text="拨号" />

MainActivity

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;public class MainActivity extends Activity implements OnClickListener {private EditText ed_number;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ed_number = ( EditText)findViewById(R.id.ed_number);//拨号按键Button btn_call = (Button)findViewById(R.id.btn_call);btn_call.setOnClickListener(this);Button btn_1 = (Button)findViewById(R.id.btn_1);btn_1.setOnClickListener(this);Button btn_2 = (Button)findViewById(R.id.btn_2);btn_2.setOnClickListener(this);Button btn_3 = (Button)findViewById(R.id.btn_3);btn_3.setOnClickListener(this);Button btn_4 = (Button)findViewById(R.id.btn_4);btn_4.setOnClickListener(this);Button btn_5 = (Button)findViewById(R.id.btn_5);btn_5.setOnClickListener(this);Button btn_6 = (Button)findViewById(R.id.btn_6);btn_6.setOnClickListener(this);Button btn_7 = (Button)findViewById(R.id.btn_7);btn_7.setOnClickListener(this);Button btn_8 = (Button)findViewById(R.id.btn_8);btn_8.setOnClickListener(this);Button btn_9 = (Button)findViewById(R.id.btn_9);btn_9.setOnClickListener(this);Button btn_0 = (Button)findViewById(R.id.btn_0);btn_0.setOnClickListener(this);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}public void onClick(View v) {// TODO Auto-generated method stubswitch(v.getId()){case R.id.btn_call:{callPhone();break;}case R.id.btn_1:{ed_number.append("1");break;}case R.id.btn_2:{ed_number.append("2");break;}case R.id.btn_3:{ed_number.append("3");break;}case R.id.btn_4:{ed_number.append("4");break;}case R.id.btn_5:{ed_number.append("5");break;}case R.id.btn_6:{ed_number.append("6");break;}case R.id.btn_7:{ed_number.append("7");break;}case R.id.btn_8:{ed_number.append("8");break;}case R.id.btn_9:{ed_number.append("9");break;}case R.id.btn_0:{ed_number.append("0");break;}default:break;}}private void callPhone() {String number = ed_number.getText().toString().trim();if("".equals(number)){//弹出提示框//参数: 上下文,内容,提示框显示的时间Toast.makeText(MainActivity.this, "电话号码不能为空", Toast.LENGTH_LONG).show();return;}System.out.println("点击了拨号按钮"+number);//创建一个意图对象Intent myIntent = new Intent();//设置意图myIntent.setAction(Intent.ACTION_CALL);//设置为拨打电话的意图//设置电话号码myIntent.setData(Uri.parse("tel:"+number));//启动意图startActivity(myIntent);//添加拨号权限AndroidManifest.xml--->Permissions}}

程序崩溃


如果运行的程序出现了这种崩溃,只需在加下权限就ok
步骤:双击AndroidManifet.xml文件

点击权限这栏


选择CALL_PHONE

再次运行即可。

测试

输入空然后拨号:

正常拨号:


基本功能完成,测试成功。

总结

虽然功能基本完成了,但是由于监听按键是一个个加入的,导致未能拥有较好的空间复杂度,还待改善。

晚安 520快乐。

Android(一)使用eclipse开发一个Android拨号器相关推荐

  1. android中的插件开发框架,设计并开发一个 Android 的插件化框架

    结合动态加载系列文章的分析,现在开始设计并开发一个 Android 的插件化框架,命名为 Frontia.Frontia 有 "前端" 的意思,寓意着 Android 插件能像前端 ...

  2. Android | 教你如何开发一个拍照翻译小程序

    华为机器学习服务(ML Kit) 提供机器学习套件,为开发者应用机器学习能力开发各类应用提供优质体验.得益于华为长期技术积累,ML Kit 为开发者提供简单易用.服务多样.技术领先的机器学习能力,助力 ...

  3. Android两个小Demo之电话拨号器和短信发送器

    两个简单的小案列 <1>电话拨号器 实现一个电话拨号器,我们分为简单的三步走: 1.在layout中写好布局 2.在MainActivity中写出对应的事件 3.在Manifest中配置好 ...

  4. android circleimageview 导入到eclipse,android项目从Eclipse迁移到Android studio中常见问题解决方法.pdf...

    android项项目目从从Eclipse迁迁移移到到Android studio 中中常常见见问问题题解解决决方方法法 android项目从Eclipse迁移到Android studio中经常会遇到 ...

  5. 《教我兄弟学Android逆向01 编写第一个Android程序》

    前言 之所以准备写这一系列逆向的教程是因为有一些同学私信我说自己想学习Android逆向但是不知道怎么去学习 包括自己身边的一些计算机专业的同学 在大学里面老师讲的那些东西要么是自己不感兴趣 要么是自 ...

  6. ***JAVA*和*Eclipse*开发一个换装小游戏**

    JAVA和Eclipse开发一个换装小游戏** 家有一女如有一宝,最近女朋友的少女心有点爆棚,作为一个计算机专业的人,我的情商简直是低到吓人,但是我还是想到了,亲自给女朋友做一个换装的小游戏,来满足女 ...

  7. *使用Eclipse开发一个Java Web网站

    一.配置Web服务器:Build Path 参考链接:http://blog.csdn.net/qq_37546891/article/details/79192392 二.设置jsp文件默认UTF- ...

  8. 《教我兄弟学Android逆向03 破解第一个Android游戏 》

    上一篇 <教我兄弟学Android逆向02  破解第一个Android程序  >我带着你破解了我们自己编的一个小程序 里面我分析并讲解的一些smali语法你都记住了 给你布置的课后作业你发 ...

  9. 如何自己开发一个Android APP(3)——XML和Android

    XML是一种用于保存数据值的语言. XML是一种标记语言,类似于HTML--如果之前接触过Web开发的话.XML文件利用树状结构作为数据模型.通常来说,一个布局文件拥有一个根布局元素,并将其作为特定布 ...

最新文章

  1. 计算机网络:自顶向下方法(第七版)Wireshark实验指南
  2. tensorrt动态输入分辨率尺寸
  3. CUDA编程之快速入门
  4. 分析nat穿越(未完成)
  5. 软考初级——计算机系统基础知识
  6. Visual Studio 窗口的图标、图片资源 $this.Icon 在哪查看
  7. java label 超链接_Swing之带超链接的label简单实现。
  8. UVA497 Strategic Defense Initiative【LIS+DP】
  9. 数字电子技术基础(十):SR锁存器
  10. 架构之美 | 按图索骥,就能做好架构图!
  11. Matlab中散点图绘制详细教程scatter函数(附matlab代码)
  12. 新版SpringCloudGateway网关 切面修改方法入参
  13. 你想象不到这些明星竟然是程序员出身
  14. 继机器人披萨后,我又吃了个机器人汉堡!
  15. 知识产权贯标认证的好处,如何申请?
  16. vue-cli生成的模板各个文件详解(转)
  17. 删除PowerPoint的备注
  18. “全量增量” 与 “增量同步” 一文了解清楚【建议收藏】
  19. 计算机组装和维修资料库,电脑组装与维修题库资料.doc
  20. 2022年第四届人工智能与机器学习国际会议(FAIML 2022)

热门文章

  1. 【c语言】4 并发服务器
  2. 删除内置不卡米教程_影视特效后期AE CC零基础入门到高级教程
  3. STM32官方固件库代码解读--GPIO
  4. [附源码]计算机毕业设计springboot疫情物资管理系统
  5. 《图解HTTP》思维导图
  6. android边直播边录制视频软件,实现Android本机 视频录制播放 边录边放
  7. 3DES的算法原理浅析
  8. 常见国内微博的字数限制 javascript判断
  9. 2024北京邮电大学计算机考研信息汇总
  10. 王者荣耀为什么这么火