一个不同以往的电话拨号器
package com.mycompany.myapp;import android.app.*;import android.os.*;import android.widget.*;import android.view.View.*;import android.view.*;import android.content.*;import android.net.*;public class MainActivity extends Activity {private EditText et_number; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); et_number=(EditText)findViewById(R.id.mainEditText);Button btn_call=(Button)findViewById(R.id.mainButton);btn_call.setOnClickListener(new myclicklistener()); }private class myclicklistener implements OnClickListener{@Overridepublic void onClick(View p1){String number=et_number.getText().toString().trim();if("".equals(number)){Toast.makeText(MainActivity.this,"number不能为空",Toast.LENGTH_LONG).show();return;}Intent intent=new Intent();intent.setAction(intent.ACTION_CALL);intent.setData(Uri.parse("tel:" number));startActivity(intent);}}}
评论