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);
}
}
}
}
答案 0 :(得分:3)
你错过了“);”匹配“(”这一行:
btnSendSMS.setOnClickListener(new View.OnClickListener(){
(如果你打算正确地缩进你的代码,那将会更容易看到。花在你的代码风格上的时间实际上会让你更有效率......根据我的经验。)