今天写了如下代码:
Button bt1=(Button)findViewById(R.id.btn1);
bt1.setOnClickListener(bt1lis);
运行后报空指针错误。
后来把
Button bt1=(Button)findViewById(R.id.btn1);
改为
Button bt1=(Button)this.findViewById(R.id.btn1);
就没问题了。
更为有意思的是,加上this跑起来以后,再把this去掉,也不报错了,android闹脾气了?