这是实现的拨号的小程序 ,不知道为什么一运行就强制关闭,配置文件中我也加了<uses-permission android:name="android.permission.CALL_PHONE"/> 这句啦 ,不知道是什么问题 ,新手请大侠帮忙 ,十份着急 
package mySoft.Phone;import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;public class SharpPhoneActivity extends Activity {
   private Button button =null;
   private EditText edittext = null;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        button = (Button)findViewById(R.string.button);
        edittext = (EditText)findViewById(R.string.mobile);
     
        
        button.setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                                String phone = edittext.getText().toString();
                                Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phone));
                                startActivity(intent);
                        }
                });
    }
}
配置清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mySoft.Phone"
    android:versionCode="1"
    android:versionName="1.0" >    <uses-sdk android:minSdkVersion="10" />    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".SharpPhoneActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>    </application><uses-permission android:name="android.permission.CALL_PHONE"/> 
</manifest>

解决方案 »

  1.   

    首先,你要在main.xml里面定义1个Button和EditText,并定义其id号分别为button和mobile,然后,在调用的时候,是用R.id.而不是R.string
    button = (Button)findViewById(R.id.button);
    edittext = (EditText)findViewById(R.id.mobile);
     
      

  2.   

    button = (Button)findViewById(R.string.button);  //这应该是R.id.xxx
      edittext = (EditText)findViewById(R.string.mobile);//这应该是R.id.xxx
    这两个你获取肯定是空了,怎么会是string.xxx呢。
      

  3.   

    总共也就这么几行简单代码,一启动就报错
    也就只可能是
    button = (Button)findViewById(R.string.button);
      edittext = (EditText)findViewById(R.string.mobile);
        
        
      button.setOnClickListener(new OnClickListener() {
    这三行代码了。然后看一下,第三行可能性最大,怀疑button没获取到,再细看一下获取方式,发现就是string。
      

  4.   

    exception的详细信息会报告错误位置的吧