我正在为Android游戏项目编写此代码:
public class GameActivity extends Activity implements OnClickListener {
Button b1 = null;
Button b2 = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
b1 = new Button(this);
b2 = new Button(this);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// how parameter "v" got its value.,
// and where it was initialized???
}
}
Run Code Online (Sandbox Code Playgroud)
我注意到onClick(View v)onClickListener 的方法,并想问一下参数"View v"在哪里初始化?我知道它包含了点击视图的参考,但它在哪里以及如何获得它的价值?
同样的问题:
public void actionPerformed(ActionEvent e){
// where/how it initialized "e" ??
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
117 次 |
| 最近记录: |