-4

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

}

4

2 回答 2

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);
        }
    }
于 2013-08-27T12:57:24.427 回答
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);
        }
    });

 }
}
于 2013-08-27T13:16:55.740 回答