我对Android开发有点新手,在尝试创建一个名为areacircle的另一个活动的Intent时收到此错误:
Syntax error on token "(",; expected
Syntax error on token ")",; expected
void is an invalid type for the variable acircle
编辑:我添加了整个代码块
我希望此代码可以帮助您:
public class findmy extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.findmy);
public void acircle(View view) {
Intent acircleIntent = new Intent(this, areacircle.class);
startActivity(acircleIntent);
}
}
}
答案 0 :(得分:1)
更改
public void acircle(View view) {
Intent acircleIntent = new Intent(this, areacircle.class);
startActivity(acircleIntent);
};
}
要:
在;
之后从第四行删除}
,您的问题应该消失。
public void acircle(View view) {
Intent acircleIntent = new Intent(this, areacircle.class);
startActivity(acircleIntent);
}
}
答案 1 :(得分:0)
如果您在点击按钮
上查看其他活动,请尝试这样做public class findmy extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.findmy);
Button d = (Button) findViewById(R.id.btnTitle3);
d.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent acircleIntent = new Intent(this, areacircle.class);
startActivity(acircleIntent);
}
});
}
}