android中Activity之間跳轉

package com.yarin.android.Examples_03_01;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Activity01 extends Activity
{
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Button button = (Button) findViewById(R.id.button1);
		button.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v)
			{
				Intent intent = new Intent();
				intent.setClass(Activity01.this, Activity02.class);
				startActivity(intent);
				Activity01.this.finish();
			}
		});
	}
}
package com.yarin.android.Examples_03_01;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Activity02 extends Activity
{
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main2);
		Button button = (Button) findViewById(R.id.button2);
		button.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v)
			{
				Intent intent = new Intent();
				intent.setClass(Activity02.this, Activity03.class);
				startActivity(intent);
				Activity02.this.finish();
			}
		});
	}

}

 

 

 

 

 

package com.yarin.android.Examples_03_01;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Activity03 extends Activity
{
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main3);
		Button button = (Button) findViewById(R.id.button3);
		button.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v)
			{
				
				Intent intent = new Intent();
				
				intent.setClass(Activity03.this, Activity01.class);
				
				startActivity(intent);
				
				Activity03.this.finish();
			}
		});
	}
}
©️2020 CSDN 皮肤主题: 程序猿惹谁了 设计师:上身试试 返回首页