-3

ADT 说最后第三行存在语法错误,并且该行有多个标记。只有错误导致我的 ADT 阻止编译。我相信它位于代码的上部,只是找不到。希望有人帮忙!

public class MainActivity extends Activity {

Button btnSendSMS;

/** Called when the activity is first created. */

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


btnSendSMS = (Button) findViewById(R.id.btnSendSMS);


btnSendSMS.setOnClickListener(new View.OnClickListener(){

@Override       
public void onClick(View v)
{
    sendSMS("5566", "Hello my friends!");
}

public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

//---sends an SMS message to another device---
private void sendSMS(String phoneNumber, String message)
{
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, null, null);




}
}
}

}

4

1 回答 1

3

您缺少“);” 与此行上的“(”匹配:

btnSendSMS.setOnClickListener(new View.OnClickListener(){

(如果你费心正确缩进你的代码,它会更容易看到。花时间在你的代码风格上实际上会让你更有效率......根据我的经验。)

于 2013-06-26T15:30:10.993 回答