似乎无法解决此语法错误,可能是因为我已经在屏幕前已经太久了。请帮忙!
package com.example.facilietiesreviewapp;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class HomeActivity extends Activity {
Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
addListenerOnButton();
}
public void addListenerOnButton() {
final Context context = this;
button = (Button) findViewById(R.id.addStationBtn);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, AddStationActivity.class);
startActivity(intent);
}
}); /*SEMICOLON ERROR-Syntax error, insert "}" to complete
MethodBody*/
这是错误的↑,我上面的分号是红色的下划线。
//Search button link
public void addListenerOnButtonSearch() {
final Context context = this;
button = (Button) findViewById(R.id.startSearchBtn);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, SearchActivity.class);
startActivity(intent);
}
});
//Search button link
}
}
答案 0 :(得分:2)
在开始addListenerOnButton
public void addListenerOnButtonSearch()
方法
所以在}); /*SEMICOLON ERROR-Syntax error, insert "}" to complete
MethodBody*/
答案 1 :(得分:0)
您的addListenerOnButton
方法未关闭,最后应该有一个}
括号。