令牌Android开发错误的语法错误

时间:2013-08-27 12:53:24

标签: android

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

}

2 个答案:

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

 }
}