AndroidManifest.xml
package="com.hyl.phone" android:versionCode="1" android:versionName="1.0">
hyl.xml
请输入手机号码
拨打此号码
main.xml
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="wrap_content" android:text="@string/mobellabel"
android:id="@+id/TextView01"
/>
android:layout_width="fill_parent" android:layout_height="wrap_content" />
android:layout_width="wrap_content" android:layout_height="wrap_content" />
phoneActivity.java
package com.hyl.phone;
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;
public class phoneActivity extends Activity {
/** Called when the activity is first created. */
private Button button;
private EditText editText;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button= (Button)this.findViewById(R.id.Button01);
editText=(EditText) this.findViewById(R.id.EditText01);
button.setOnClickListener(new ButtonListener());
}
private final class ButtonListener implements View.OnClickListener{
public void onClick(View v) {
String phonenum=editText.getText().toString();
//android.intent.action.CALL=Intent.ACTION_CALL
Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phonenum));
startActivity(intent);
}
}
}