Android 按钮事件和界面跳转

作者: 傻猫    分类: 搞软件     发布时间: 07-07 23:06    浏览次数: 6290     无留言

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

 Button button = (Button) findViewById(R.id.button);
  button.setOnClickListener(text_view_button_listener);

 }

 private Button.OnClickListener text_view_button_listener = new Button.OnClickListener() {
  public void onClick(View v) {
   Intent intent = new Intent();
   intent.setClass(MainActivity.this, ViewTextActivity.class);
   startActivity(intent);
  }
 };

添加新评论