使用Android Studio显示错误,源码如下
package com.example.hello.test;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import android.util.Log;
public class MainActivity extends Activity {
private Button bt1;
private Button bt2;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt1 = (Button) findViewById(R.id.button3);
bt2 = (Button) findViewById(R.id.button4);
/*
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
*/
bt1.setOnClickListener(new MyOnClickListener(){
private void onClick(view v) {
super.onClick(v);
Toast.makeText(MainActivity.this,"bt1要执行的逻辑",2).show();
}
});
}
}
class MyOnClickListener implements View.OnClickListener {
public void onClick(View v) {
Log.i("tag","父类的onclick事件");
}
}