view plain
package cn.csdn.hb; import Android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class Change extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn1 = (Button) findViewById(R.id.button1); btn1.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Button1(); } }); } public void Button1() { setContentView(R.layout.second); Button btn2 = (Button) findViewById(R.id.button2); btn2.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Button2(); } }); } public void Button2() { setContentView(R.layout.main); Button b1 = (Button) findViewById(R.id.button1); b1.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Button1(); } }); } }b、利用键盘或触摸实现
4、不同activity间的切换
如果想使两个Activity切换,那么肯定要使用我们具有桥梁作用的Intent