它在这里给了我一个错误,尽管 setX(int) 是按钮类型,但它没有定义。
public class TouchMe extends Activity implements View.OnClickListener {
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tuchme);
btn = (Button) findViewById(R.id.btn);
btn.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case (R.id.btn): {
Random r = new Random();
int x = r.nextInt(480 - buttonWidth);
int y = r.nextInt(800 - buttonHeight);
btn.setX(x); // give me error here that setX(int) is not defined
btn.setY(y); // is button type.
}
}
这里给我的错误是 setX(int) is not defined is button type。请帮我。