本文共 1942 字,大约阅读时间需要 6 分钟。
让我们看一下原代码:
- package com.smart.activity;
-
- import android.app.Activity;
- import android.content.ComponentName;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
-
- public class Main extends Activity {
-
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Button button = (Button) this.findViewById(R.id.button);
- button.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
-
-
- Intent intent = new Intent(Main.this,SmartActivity.class);
-
- Main.this.startActivity(intent);
-
-
-
-
-
-
-
-
- }
- });
- }
- }
- package com.smart.activity;
-
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
-
- public class SmartActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- setContentView(R.layout.smart);
- Button button2 = (Button) this.findViewById(R.id.button2);
- button2.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
-
-
- Intent intent = new Intent(SmartActivity.this,Main.class);
-
- SmartActivity.this.startActivity(intent);
-
-
-
-
-
-
-
-
- }
- });
-
- }
-
-
-
-
- }
本文转自 llb988 51CTO博客,原文链接:http://blog.51cto.com/llb988/490078,如需转载请自行联系原作者