import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.content.Intent;
import android.view.View.OnClickListener;
public class FivepiecesActivity extends Activity implements OnClickListener {
//该对象继承Activity并且实现onClickListener接口
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button about_button=(Button) findViewById(R.id.about_button);
Button exit_button=(Button)findViewById(R.id.exit_button); //设置button的ID about_button.setOnClickListener(this);
exit_button.setOnClickListener(this);
//设置监听器,监视按钮按下时的动作 }
public void onClick(View v){
switch(v.getId()){
case R.id.about_button:
Intent i=new Intent(this,About.class);
startActivity(i);
break;
case R.id.exit_button:
finish();
break;
}
}