我的理解是,当我创建一个侦听点击的按钮对象时,我必须:
OnClickListner使它听取用户的点击onClick在用户单击按钮后执行操作现在,
setOnClickListener符合上述逻辑?setOnClickListener? OnClickListener? View.OnClickListener? 这是我在Android Dev中发现的:
//The example below shows how to register an on-click listener for a Button.
// Create an anonymous implementation of OnClickListener
private OnClickListener mCorkyListener = new OnClickListener() {
public void onClick(View v) {
// do something when the button is clicked
}
};
protected void onCreate(Bundle savedValues) {
...
// Capture our button from layout
Button button = (Button)findViewById(R.id.corky); …Run Code Online (Sandbox Code Playgroud)