package com.example.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
private Button login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
login = (Button) findViewById(R.id.button1);
/*
* 监听事件通过第一种方式实现( )
*/
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("我的按钮被点击了!");
}
});
}
}