zoukankan      html  css  js  c++  java
  • 06_电话拔号器

    public class MainActivity extends Activity {
        private EditText mobileText;
        private Button button;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            mobileText = (EditText) findViewById(R.id.mobile);
            button = (Button) this.findViewById(R.id.button);
            
            //方法一:
            button.setOnClickListener(new ButtonClikListener());
            /*方法二:————不建议
            button.setOnClickListener(new View.OnClickListener() {
                
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    String number = mobileText.getText().toString();
                    
                    Intent intent = new Intent();
                    intent.setAction("android.intent.action.CALL");
                    intent.addCategory("android.intent.category.DEFAULT");
                    intent.setData(Uri.parse("tel:"+number));
                    startActivity(intent);//    方法内部会自动为intent 添加类别"android.intent.category.DEFAULT",所以intent.addCategory可以不写                
                }
            }*/
        }
        
        private final class ButtonClikListener implements View.OnClickListener{
            public void onClick(View v){
                String number = mobileText.getText().toString();
                
                Intent intent = new Intent();
                intent.setAction("android.intent.action.CALL");
                intent.addCategory("android.intent.category.DEFAULT");
                intent.setData(Uri.parse("tel:"+number));
                startActivity(intent);//    方法内部会自动为intent 添加类别"android.intent.category.DEFAULT",所以intent.addCategory可以不写
            }
        }
    }
  • 相关阅读:
    Get code into Bitbucket fast using Atlassian's SourceTree or the command line
    Django+angularJs
    修改默认python版本
    重拾python mac1.9.2
    REST
    Parameters.Add Parameters.Addrange
    sql建表前删除存在的同名表
    C#1.0
    [转]C#究竟能给开发者带来什么
    Laravel中上传图片至七牛云
  • 原文地址:https://www.cnblogs.com/carl2380/p/4157071.html
Copyright © 2011-2022 走看看