smart_Activity互相跳转——基础编

简介:

 

 

 

 

 

 

让我们看一下原代码:

  1. package com.smart.activity;  
  2.  
  3. import android.app.Activity;  
  4. import android.content.ComponentName;  
  5. import android.content.Intent;  
  6. import android.os.Bundle;  
  7. import android.view.View;  
  8. import android.widget.Button;  
  9.  
  10. public class Main extends Activity {  
  11.  
  12.     // ANDROID系统,组件与组件之间是通过,INTENT进行通信的。  
  13.     @Override 
  14.     public void onCreate(Bundle savedInstanceState) {  
  15.         super.onCreate(savedInstanceState);  
  16.         setContentView(R.layout.main);  
  17.         Button button = (Button) this.findViewById(R.id.button);  
  18.         button.setOnClickListener(new View.OnClickListener() {  
  19.  
  20.             @Override 
  21.             public void onClick(View v) {  
  22.                 // 打开新的Activity  
  23.                 //第一种方法调用  
  24.                  Intent intent = new Intent(Main.this,SmartActivity.class);  
  25. //              打开应用的组件  
  26.                  Main.this.startActivity(intent);  
  27.                 //第二种方法调用  
  28. //              Intent intent = new Intent();  
  29. //              intent.setClass(Main.this, SmartActivity.class);  
  30.                 //第三种方法调用  
  31. //              Intent intent = new Intent();  
  32. //              intent.setComponent(new ComponentName(Main.this, SmartActivity.class));  
  33.                 //意思是讲三种方法调查用,意是一样的,  
  34.                 //一般来讲用第一种  
  35.             }  
  36.         });  
  37.     }  

 

  1. package com.smart.activity;  
  2.  
  3. import android.app.Activity;  
  4. import android.content.Intent;  
  5. import android.os.Bundle;  
  6. import android.view.View;  
  7. import android.widget.Button;  
  8.  
  9. public class SmartActivity extends Activity {  
  10.  
  11.     @Override 
  12.     protected void onCreate(Bundle savedInstanceState) {  
  13.         //关于这行代码,是完成界面的代码  
  14.         super.onCreate(savedInstanceState);  
  15.         setContentView(R.layout.smart);  
  16.         Button button2 = (Button) this.findViewById(R.id.button2);  
  17.         button2.setOnClickListener(new View.OnClickListener() {  
  18.  
  19.             @Override 
  20.             public void onClick(View v) {  
  21.                 // 打开新的Activity  
  22.                 //第一种方法调用  
  23.                  Intent intent = new Intent(SmartActivity.this,Main.class);  
  24. //              打开应用的组件  
  25.                  SmartActivity.this.startActivity(intent);  
  26.                 //第二种方法调用  
  27. //              Intent intent = new Intent();  
  28. //              intent.setClass(Main.this, SmartActivity.class);  
  29.                 //第三种方法调用  
  30. //              Intent intent = new Intent();  
  31. //              intent.setComponent(new ComponentName(Main.this, SmartActivity.class));  
  32.                 //意思是讲三种方法调查用,意是一样的,  
  33.                 //一般来讲用第一种  
  34.             }  
  35.         });  
  36.           
  37.     }  
  38.  
  39.       
  40.       
  41.       
  42. }  

 

 

 

本文转自 llb988 51CTO博客,原文链接:http://blog.51cto.com/llb988/490078,如需转载请自行联系原作者

相关文章
|
Android开发
【Android 逆向】IDA 工具使用 ( 重命名函数 | 添加注释 | 添加标签 / 跳转标签 | 代码跳转前进 / 后退 )(二)
【Android 逆向】IDA 工具使用 ( 重命名函数 | 添加注释 | 添加标签 / 跳转标签 | 代码跳转前进 / 后退 )(二)
212 0
【Android 逆向】IDA 工具使用 ( 重命名函数 | 添加注释 | 添加标签 / 跳转标签 | 代码跳转前进 / 后退 )(二)
|
Java Android开发
【Android 逆向】IDA 工具使用 ( 重命名函数 | 添加注释 | 添加标签 / 跳转标签 | 代码跳转前进 / 后退 )(一)
【Android 逆向】IDA 工具使用 ( 重命名函数 | 添加注释 | 添加标签 / 跳转标签 | 代码跳转前进 / 后退 )(一)
442 0
【Android 逆向】IDA 工具使用 ( 重命名函数 | 添加注释 | 添加标签 / 跳转标签 | 代码跳转前进 / 后退 )(一)
|
监控 Java 开发工具
basic4android 开发教程翻译(一)建立模拟器和第一个Hello worlrd程序
如果你还没有安装Basic4android和Java SDK,请先参照后面的链接里面的安装和配置方法:http://www.basic4ppc.com/forum/basic...droid-sdk.html 在这个教程里面,我们将建立一个新的AVD (Android Virtual Device)并生成模拟器实例.
1697 0
|
iOS开发 开发者
iOS开发-新版Xcode在Appdelegate中通过代码控制跳转,不使用系统默认跳转到默认ViewController
iOS开发-新版Xcode在Appdelegate中通过代码控制跳转,不使用系统默认跳转到默认ViewController
291 0
iOS开发-新版Xcode在Appdelegate中通过代码控制跳转,不使用系统默认跳转到默认ViewController
DirectShow中写push模式的source filter流程 + 源代码(内附详细注释)
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">虽然网上已有很多关于DirectShow写source filter的资料,不过很多刚开始学的朋友总说讲的不是很清楚(可能其中作者省略了许多他认为简</p> <p style="color: rgb(51, 51,
1726 0
|
Web App开发 BI 数据库
Report_客制化以PLSQL输出HTML标记实现WEB报表(案例)
2014-05-31 Created By BaoXinjian 一. 摘要 Oracle Report Builder开发的字符模式的报表,成为系统报表 优点 采用图形化的开发方式,比较直观 有功能强大的向导 对比较复杂格式的报表也不要通过太多代码来实现 最终结果以一个独立的...
1420 0
|
Android开发
android官方技术文档翻译——switch 语句转换
本文译自androd官方技术文档《Switch Statement Conversion》,原文地址:http://tools.android.com/tips/non-constant-fields。
714 0
|
Android开发 Kotlin
使用kotlin 进行 安卓app 的 活动跳转 与 片段跳转
使用kotlin 进行 安卓app 的 活动跳转 与 片段跳转
114 0

热门文章

最新文章