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);
}
}
}
}