标签:
1. startActivity(Intent intent): 启动其他Activity
对应关闭方法finish():结束当前Activity
1 public class MainActivity extends AppCompatActivity 2 { 3 @Override 4 protected void onCreate(Bundle savedInstanceState) 5 { 6 super.onCreate(savedInstanceState); 7 setContentView(R.layout.activity_main); 8 // 获取应用程序中的bn按钮 9 Button bn = (Button) findViewById(R.id.bn); 10 // 为bn按钮绑定事件监听器 11 bn.setOnClickListener(new View.OnClickListener() 12 { 13 @Override 14 public void onClick(View source) 15 { 16 // 创建需要启动的Activity对应的Intent 17 Intent intent = new Intent(MainActivity.this, 18 SecondActivity.class); 19 // 启动intent对应的Activity 20 startActivity(intent); 21 } 22 }); 23 } 24 }
2. startActivityForResult(Intent intent, int requestCode)
对应关闭方法: finishActivity(int requestCode) 结束以 startActivityForResult(Intent intent, int requestCode)方法启动的Activity
标签:
原文地址:http://www.cnblogs.com/starman/p/4969664.html