自制手机APP源代码

最开始是布局代码:

<span style="font-size:18px;"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="@drawable/kp"android:orientation="vertical" ><LinearLayoutandroid:id="@+id/LinearLayout6"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="horizontal" ><EditTextandroid:id="@+id/EditText1"android:layout_width="260dip"android:layout_height="wrap_content"android:layout_marginLeft="10dip"android:layout_marginRight="6dip"android:background="#FFFFFF"android:editable="false"android:enabled="false"android:singleLine="true"android:text="@string/default_number"android:textColor="#000000"android:textSize="24dip" /><Buttonandroid:id="@+id/Button_del"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/deldown"android:text=" "android:textSize="24dip" /></LinearLayout><LinearLayoutandroid:id="@+id/LinearLayout1"android:layout_width="fill_parent"android:layout_height="181dp"android:orientation="vertical" ><LinearLayoutandroid:id="@+id/LinearLayout2"android:layout_width="fill_parent"android:layout_height="32dp"android:gravity="center_horizontal"android:orientation="horizontal" ><Buttonandroid:id="@+id/Button1"android:layout_width="48dp"android:layout_height="match_parent"android:background="@drawable/c1"android:text="1"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button2"android:layout_width="49dp"android:layout_height="52dp"android:layout_marginLeft="20dip"android:layout_marginRight="20dip"android:background="@drawable/c2"android:text="2"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button3"android:layout_width="58dp"android:layout_height="match_parent"android:background="@drawable/c3"android:text="3"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /></LinearLayout><LinearLayoutandroid:id="@+id/LinearLayout3"android:layout_width="fill_parent"android:layout_height="20dp"android:layout_marginTop="20dip"android:layout_weight="0.21"android:gravity="center_horizontal"android:orientation="horizontal" ><Buttonandroid:id="@+id/Button4"android:layout_width="33dp"android:layout_height="54dp"android:background="@drawable/c4"android:text="4"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button5"android:layout_width="55dp"android:layout_height="match_parent"android:layout_marginLeft="20dip"android:layout_marginRight="20dip"android:background="@drawable/c5"android:text="5"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button6"android:layout_width="56dp"android:layout_height="36dp"android:background="@drawable/c6"android:text="6"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /></LinearLayout><LinearLayoutandroid:id="@+id/LinearLayout4"android:layout_width="fill_parent"android:layout_height="22dp"android:layout_marginTop="20dip"android:layout_weight="0.11"android:gravity="center_horizontal"android:orientation="horizontal" ><Buttonandroid:id="@+id/Button7"android:layout_width="31dp"android:layout_height="match_parent"android:background="@drawable/c7"android:text="7"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button8"android:layout_width="84dp"android:layout_height="32dp"android:layout_marginLeft="20dip"android:layout_marginRight="20dip"android:background="@drawable/c8"android:text="8"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button9"android:layout_width="68dp"android:layout_height="34dp"android:background="@drawable/c9"android:text="9"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /></LinearLayout><LinearLayoutandroid:id="@+id/LinearLayout5"android:layout_width="fill_parent"android:layout_height="25dp"android:layout_marginTop="20dip"android:layout_weight="0.20"android:gravity="center_horizontal"android:orientation="horizontal" ><Buttonandroid:id="@+id/Button_dial"android:layout_width="wrap_content"android:layout_height="46dp"android:background="@drawable/dial"android:text=" "android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button0"android:layout_width="wrap_content"android:layout_height="43dp"android:layout_marginLeft="20dip"android:layout_marginRight="20dip"android:background="@drawable/c0"android:text="0"android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /><Buttonandroid:id="@+id/Button_cancel"android:layout_width="wrap_content"android:layout_height="42dp"android:background="@drawable/dialcancel"android:text=" "android:textSize="54dip"android:textStyle="bold"android:typeface="serif" /></LinearLayout></LinearLayout></LinearLayout></span>

然后是主函数

package com.example.mzphone;import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.Window;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.net.Uri;public class MainActivity extends Activity {int[] numButtonIds = { R.id.Button0, R.id.Button1, R.id.Button2,R.id.Button3, R.id.Button4, R.id.Button5, R.id.Button6,R.id.Button7, R.id.Button8, R.id.Button9 };@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_main);//为删除键添加监听器Button bDel=(Button)this.findViewById(R.id.Button_del);bDel.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubEditText et=(EditText)findViewById(R.id.EditText1);String num=et.getText().toString();num=(num.length()>1)?num.substring(0,num.length()-1):"";et.setText(num);}});//为拨号键添加监听器Button bDial=(Button)this.findViewById(R.id.Button_dial);bDial.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubEditText et=(EditText)findViewById(R.id.EditText1);String num=et.getText().toString();Intent dial=new Intent();dial.setAction("android.intent.action.CALL");dial.setData(Uri.parse("tel://"+num));startActivity(dial);}}); //为退出按钮添加监听器Button bCancel=(Button)this.findViewById(R.id.Button_cancel);bCancel.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubMainActivity.this.finish();}});//为0~9数字按钮创建监听器View.OnClickListener numListener=new View.OnClickListener(){@Overridepublic void onClick(View v) {// TODO Auto-generated method stubButton tempb=(Button)v;EditText et=(EditText)findViewById(R.id.EditText1);et.append(tempb.getText());}};//为所有的数字按键添加监听器for (int id:numButtonIds){Button tempb=(Button)this.findViewById(id);tempb.setOnClickListener(numListener);}}@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;}}<span style="font-size:18px;">
</span>

至于权限文件,只需添加一行:

<uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="18" /><uses-permission android:name="android.permission.CALL_PHONE"/>   //这一行是需要自己添加的

然后运行就可以啦

绝对可以运行,至于layout中涉及到的一些照片,按自己的喜好选择几张就行啦

自制智能手机电话APP相关推荐

  1. 为老年人熟悉智能手机的APP

    为老年人熟悉智能手机的APP 转载于:https://www.cnblogs.com/xj626852095/p/3648142.html

  2. 【Android】Android开发初学者实现拨打电话的功能,拨打电话app小demo实现

    作者:程序员小冰,GitHub主页:https://github.com/QQ986945193 新浪微博:http://weibo.com/mcxiaobing 首先先给大家看一下最终实现的效果: ...

  3. 自制蓝牙手机app控制stm8/stm32/C51板载LED

    这里来分享下,自制手机app来控制单片机上的LED,以实现上位机,下位机的通讯 这次分享的是蓝牙app控制stm8,stm32,C51的我前面的文章分享过,不懂的可以看看–>传送门 原理很简单, ...

  4. android自制小说阅读APP

    历时一星期零两天,APP于今日开发完成,在此附上成品,有兴趣的可以看看. github地址:https://github.com/hellojessehao/EnjoyReading 如果对你有所帮助 ...

  5. 自制APP连接OneNET---实现数据监控和下发控制(HTTP)

    文章目录 前言 一.前期准备 二.功能介绍 1.自制APP页面展示 三.使用SSCOM串口助手连接OneNET 1.串口助手配置 2.新增数据流 3.查询数据流 4.删除数据流 5.查询历史数据 6. ...

  6. Android 10.0 Launcher3 电话和短信app图标显示未读短信和未接来电的条数

    最近客户有需求要求在电话app图标显示未接来电的条数 在短信app图标上显示未读信息的条数 根据需求首选要在Launcher3的Launcher.java中,启动launcher时,查询未读短信和未接 ...

  7. Android 11.0 12.0Launcher3 电话和短信app图标显示未读短信和未接来电的条数

    在11.0 12.0产品开发中,最近客户有需求要求在电话app图标显示未接来电的条数 在短信app图标上显示未读信息的条数 根据需求首选要在Launcher3的Launcher.java中,启动lau ...

  8. Android 12.0Launcher3 电话和短信app图标显示未读短信和未接来电的条数

    1.概述 在12.0产品开发中,最近客户有需求要求在电话app图标显示未接来电的条数 在短信app图标上显示未读信息的条数 根据需求首选要在Launcher3的Launcher.java中,启动lau ...

  9. 回归初心才是智能家居APP掘金市场的制胜关键

    OFweek智能家居网讯:苹果第一代iPod诞生时,乔布斯多次强调要"将1000首音乐装进口袋",但他或许没有想到,如今智能家居APP的兴起,让整个家放进口袋成为了可能.2015年 ...

最新文章

  1. 22. linux 常用命令
  2. P1525 关押罪犯
  3. c语言五子棋坐标覆盖,跪求C语言五子棋悔棋部分实现
  4. why there is always a HTTP 302 redirect when clicking workcenter
  5. Linux 系统应用编程——文件I/O
  6. SqlServer2008r2卸载
  7. 对象序列化和反序列化是怎么回事
  8. Mac python入门:安装python并新建python项目
  9. PHP如何关闭notice级别的错误提示
  10. 智慧城市系列之智能交通系统(ITS)
  11. font标签及其属性
  12. org.apache.ibatis.binding.BindingException: Type interface com.java.mapper.UserMapper is not known t
  13. 半年销售100万辆 关注比亚迪后300万时代
  14. 2019最新 BAT、TMD等公司技术面试题及其答案
  15. 【vue】vue中axios的使用及vue生命周期详解_07
  16. 序列标注的BIO标注体系
  17. Jpa第一话 -- Springboot集成Jpa和Mybatis以及Jpa的最全使用
  18. Linux驱动程序教程:如何编写简单的Linux设备驱动程序
  19. 四川方言词汇集(一)
  20. 【Erlang】学习笔记-erlang基础语法

热门文章

  1. 火遍日本 IT 界的深度学习入门书,你读完了吗?
  2. 提早两天向同事发新年祝福
  3. android touch事件无反应,触摸屏 无响应
  4. 计算机设备选型的基本原则,设备选型的概念和选型依据
  5. vxe-input vue 日期选择组件带农历节日、小圆点提醒
  6. c语言法定节日日历程序,一个完整的日历程序(含有农历)
  7. 数据分析中的数据处理以及特征分析
  8. 小程序开发学习一:开发语言解析
  9. int[]是什么类型?
  10. Docker基础认识与docker安装以及环境配置