试试这个,不过界面可能丑了点
package my.phones;
import javax.security.auth.PrivateCredentialPermission;
import android.R.anim;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SimpleAdapter.ViewBinder;
public class MainActivity extends Activity {
private EditText mobileText;
/** 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=(Button) this.findViewById(R.id.button);//转化成button格式
button.setOnClickListener(new ButtonClickListenr());
}
private final class ButtonClickListenr 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);//通过意图激活activity组件,方法内部会自动为意图添加android.intent.category.DEFAULT可删掉
}
}
}
|