public class ActivityListener extends Activity implements OnClickListener{ EditText show; Button bn; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); show = (Edit
public class ActivityListener extends Activity implements OnClickListener{ EditText show; Button bn; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); show = (EditText)findViewById(R.id.show); bn = (Button)findViewById(R.id.bn); //直接使用Activity作为事件监听器 bn.setOnClickListener(this); } //实现事件处理方法 @Override public void onClick(View v) { // TODO Auto-generated method stub show.setText("bn按钮被单击了!"); }}