很多同学在写这个代码的时候,会有很多问题,我有幸做了出来,在这里分享一下,如果有用,希望点个赞。第一次发文,望多多支持。
一、创建程序:
创建一个名为InterceptCall 的Project项目文件,包名为cn.itcast.interceptcall,拦截呼叫的意思。
首先把显示界面写好:准备一张background(背景)图片,放在drawable 文件夹里面,名称是“sdz”就行,后缀名不用太在意。(android:background="@drawable/sdz")![](https://img-blog.csdnimg.cn/6d9e748354e2449880e0cdbbd1573352.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5Y-Y5YK76Iqv54mH,size_15,color_FFFFFF,t_70,g_se,x_16)
以下布局文件,activity_main.xml(不同版本中tools:context=".MainActivity"可能会有不同)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp"
android:background="@drawable/sdz"
tools:context=".MainActivity">
<EditText
android:id="@+id/et_ipnumber"
android:layout_width="match_parent