Android中Activity跳转的创建步骤总结
一、创建工程
file->new->androidapplication依次填入应用名称、工程名、包名
在工程目录下找到src/com.example.helloworldMainActivity.java
二、添加代码
packagecom.example.helloworld;
importandroid.app.Activity; importandroid.content.Intent; importandroid.os.Bundle; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button;
publicclassMainActivityextendsActivity { privateButtonbutton; @Override protectedvoidonCreate(BundlesavedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.button=(Button)this.findViewById(R.id.button1); this.button.setOnClickListener(newOnClickListener(){ @Override publicvoidonClick(Viewv){ Intentintent=newIntent(); intent.setClass(MainActivity.this,IntentActivity.class); intent.putExtra("name","HelloWorld"); startActivity(intent); } }); } }