mButton1.setOnClickListener( new Button.OnClickListener() { |
@Override |
public void onClick(View v) { |
try { |
/* 取得EditText中用户输入的字符串 */ |
String strInput = mEditText1.getText().toString(); |
if (isPhoneNumberValid(strInput) == true ) { |
/* 建构一个新的Intent并执行action.CALL的常数与透过Uri将字符串带入 */ |
Intent myIntentDial = new Intent( |
"android.intent.action.CALL" , Uri.parse( "tel:" |
+ strInput)); |
/* 在startActivity()方法中带入自定义的Intent对象以执行拨打电话的工作 */ |
startActivity(myIntentDial); |
mEditText1.setText( "" ); |
} else { |
mEditText1.setText( "" ); |
Toast.makeText(EX05_02. this , "输入的电话格式不符" , |
Toast.LENGTH_LONG).show(); |
} |
} catch (Exception e) { |
e.printStackTrace(); |
} |
} |
}); |
初级程序员
by: 小蘑菇 发表于:2013-05-05 23:09:49 顶(0) | 踩(0) 回复
收藏,备用
回复评论