80,471
社区成员




private Button button1;
//////////////////重新开始按钮////////////////
public void Rebutton(){
button1 = (Button)findViewById(R.id.button);
button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
System.out.println("13215456");//这句可以执行
// GameView.getGameView().startGame();//加上这句在点击按钮程序就会崩溃
}
});
}
public GameView(Context context, AttributeSet attrs) {
super(context, attrs);
initGameView();
}
还有一点不明白的是我没搞懂在哪里调动到了这个构造方法
因为没有找到在哪创建了GameView的对象[/quote]public class GameView extends GridLayout
之前忘记把这个贴出来了
是继承GridLayout的一个类 public GameView(Context context, AttributeSet attrs) {
super(context, attrs);
initGameView();
}
还有一点不明白的是我没搞懂在哪里调动到了这个构造方法
因为没有找到在哪创建了GameView的对象
public GameView(Context context, AttributeSet attrs) {
super(context, attrs);
initGameView();
}
public GameView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initGameView();
}
public GameView(Context context) {
super(context);
initGameView();
}
这是GameView的三个构造方法。在MainAcitivity中创建一个GameView的对象应该引用使用怎样的参数
创建对象之后对象也可以直接调用stargame方法吧。