[attachment=751]

activity_main.xml文件代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent" >

     <TextView
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/hello_world"
         tools:context=".MainActivity" />
    <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/haoma"
        />
     <Button
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/call"
         android:id="@+id/call"
         />
</LinearLayout>
MainActivity.java代码:

private EditText haoma;    
     @Override
     public void onCreate(Bundle savedInstanceState) {        
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);        
         Button call=(Button)findViewById(R.id.call);
         haoma=(EditText)findViewById(R.id.haoma);        
         call.setOnClickListener(new ButtonOnClickListener());
     }
     private final class ButtonOnClickListener implements OnClickListener{        
         @Override
         public void onClick(View v) {            
             String str=haoma.getText().toString();
             Intent intent = new Intent();            
             intent.setAction("android.intent.action.CALL");//调用android电话窗口
             intent.setData(Uri.parse("tel:"+ str));            
              startActivity(intent);
         }        
     }
AndroidMainfest.xml文件,设置拨打电话的权限:
<uses-permission android:name="android.permission.CALL_PHONE"/>
例子下载:http://dl.vmall.com/c0blir7cp3