【问题标题】:Parsing phone number from EditText to Button将电话号码从 EditText 解析为 Button
【发布时间】:2012-08-14 22:18:04
【问题描述】:

我已经知道使用按钮和 edittext 拨打电话号码的代码,但我不知道如何继续。

public void onClick(View arg0) {

    EditText num=(EditText)findViewById(R.id.editText1);
    String number = "tel:" +num.getText().toString().trim();
    Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
    startActivity(callIntent);
}

我需要允许标记为 Button1 的按钮解析此 Intent 的代码。

【问题讨论】:

  • 学习你的安卓基础知识将帮助你解决这个问题。

标签: android eclipse button


【解决方案1】:
Button Button1 = (Button) findViewById(R.id.button1_id);
Button1.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
             // Perform action on click
             EditText num=(EditText)findViewById(R.id.editText1);
             String number = "tel:" +num.getText().toString().trim();
             Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
             startActivity(callIntent);
         }
     });

【讨论】:

    猜你喜欢
    • 2010-09-18
    • 1970-01-01
    • 2012-09-14
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 1970-01-01
    • 1970-01-01
    • 2013-01-19
    相关资源
    最近更新 更多