外部监听事件运行时崩溃
public class MainActivity extends Activity {
public Button bt1,bt2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt1=(Button) findViewById(R.id.button1);
bt2=(Button) findViewById(R.id.button2);
bt1.setOnClickListener(new MyOnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
super.onClick(v);
Toast.makeText(MainActivity.this, "bt1要执行逻辑", 1).show();
}
});
}
}
class MyOnClickListener implements android.view.View.OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("tag","父类的onClick执行");
}
}
}
class MyOnClickListener implements android.view.View.OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("父类执行了!");
}
}