在构建时的以下代码段中,将 OnClickListener 添加到按钮时,我一直在中断。
package xxx.xxx.xxx;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
public class TeaActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Button AddItem = (Button)findViewById(R.id.button1);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AddItem.setOnClickListener(AddButtonHandler);
}
View.OnClickListener AddButtonHandler = new View.OnClickListener() {
public void onClick(View v) {
// it was the first button
}
};
调试时,代码将在 setOnClickListener() 调用上中断。不知道为什么