1.4Android应用之电话拔号器-创新互联

实验目的

德令哈网站建设公司创新互联建站,德令哈网站设计制作,有大型网站制作公司丰富经验。已为德令哈超过千家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的德令哈做网站的公司定做!

1.掌握简单的组件(TextView,EditText,Button)使用

2.掌握点击事件的使用

电话拔号器效果图

1.4 Android应用之电话拔号器

界面布局代码:

<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" >
  <TextView 
      android:id="@+id/title"
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"
      android:text="@string/title"/>
  
  <EditText  
      android:id="@+id/phoneNumber"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="phone"
      android:layout_below="@id/title"/>
  
  <Button 
      android:id="@+id/button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/callPhone"
      android:layout_below="@id/phoneNumber"/>
</RelativeLayout>

Java代码实现拨打电话:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button  button=(Button) findViewById(R.id.button);
        button.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
       //1.获取输入的电话号码
        EditText et=(EditText) findViewById(R.id.phoneNumber);
        String number=et.getText().toString();
       //2.创建打电话意图
        Intent intent=new Intent();
        intent.setAction(intent.ACTION_CALL);
        intent.setData(Uri.parse("tel:"+number));
        startActivity(intent);
    }

注意 在AndroidManifest.xml添加拨打电话的权限

<uses-permission android:name="android.permission.CALL_PHONE"/>

测试

1.4 Android应用之电话拔号器

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

分享名称:1.4Android应用之电话拔号器-创新互联
URL链接:https://www.cdcxhl.com/article0/dscgio.html

成都网站建设公司_创新互联,为您提供域名注册标签优化企业网站制作品牌网站设计App设计网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都做网站