android之activity跳转 窗口跳转
来源:互联网 发布:做淘宝卖小饰品赚钱吗 编辑:程序博客网 时间:2024/05/16 12:30
源码:http://download.csdn.net/detail/jzp12/4326106
本章是后面文章的基础,只涉及activity之间的跳转,不涉及activity之间参数传递。
1)在src下建立3个activity和在res/layout下建立3个xml分别是:
SwitchMulActivityActivity --- main.xml
Changshahome --- changshahome.xml
Shanghaihome --- shanghaihome.xml
注意事项:
1,xml文件的名称必须是小写
2,新建activity,SuperClass栏目中应该输入或者选择android.app.Activity
3,可通过自动在AndroidManifest.xml中添加两个activity,或者直接在AndroidManifest.xml添加代码实现。
2)直接上代码:
SwitchMulActivityActivity.java
Changshahome.java
Shanghaihome.java
main.xml
changshahome.xml
shanghaihome.xml
2)效果图:
参考:Android开发循序渐进实例1--资源文件设计以及画面跳转例子
http://blog.csdn.net/jackxinxu2100/article/details/5257186
Activity的跳转与传值
http://android.blog.51cto.com/268543/323982
本章是后面文章的基础,只涉及activity之间的跳转,不涉及activity之间参数传递。
1)在src下建立3个activity和在res/layout下建立3个xml分别是:
SwitchMulActivityActivity --- main.xml
Changshahome --- changshahome.xml
Shanghaihome --- shanghaihome.xml
注意事项:
1,xml文件的名称必须是小写
2,新建activity,SuperClass栏目中应该输入或者选择android.app.Activity
3,可通过自动在AndroidManifest.xml中添加两个activity,或者直接在AndroidManifest.xml添加代码实现。
2)直接上代码:
SwitchMulActivityActivity.java
package lostman.rigortek.china;import android.app.Activity;import android.os.Bundle;import android.widget.Button;import android.content.Intent;import android.view.View;public class SwitchMulActivityActivity extends Activity {private Button cbtGoChangsha;private Button cbtGoShanghai; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); cbtGoChangsha = (Button) findViewById(R.id.gochangsha); cbtGoShanghai = (Button) findViewById(R.id.goshanghai); do{ if(null == cbtGoChangsha || null == cbtGoShanghai){ break; } cbtGoChangsha.setOnClickListener(new Button.OnClickListener() {//实现监听器接口的匿名内部类,其中监听器本身是View类的内部接口//实现接口必须实现的onClick方法@Overridepublic void onClick(View v) {Intent cSwitchIntent = new Intent();if(null != cSwitchIntent){cSwitchIntent.setClass(SwitchMulActivityActivity.this,Changshahome.class);startActivity(cSwitchIntent);//SwitchMulActivityActivity.this.finish();}}}); cbtGoShanghai.setOnClickListener(new Button.OnClickListener() {//实现监听器接口的匿名内部类,其中监听器本身是View类的内部接口//实现接口必须实现的onClick方法@Overridepublic void onClick(View v) {Intent cSwitchIntent = new Intent();if(null != cSwitchIntent){cSwitchIntent.setClass(SwitchMulActivityActivity.this,Shanghaihome.class);startActivity(cSwitchIntent);//SwitchMulActivityActivity.this.finish();}}}); }while(false); }}
Changshahome.java
package lostman.rigortek.china;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.Button;public class Changshahome extends Activity {private Button cbtGoBasehome;private Button cbtGoShanghai;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState); setContentView(R.layout.changshahome); cbtGoBasehome = (Button) findViewById(R.id.gobasehome); cbtGoShanghai = (Button) findViewById(R.id.goshanghai); do{ if(null == cbtGoBasehome ||null == cbtGoShanghai){ break; } cbtGoBasehome.setOnClickListener(new Button.OnClickListener() {//实现监听器接口的匿名内部类,其中监听器本身是View类的内部接口//实现接口必须实现的onClick方法@Overridepublic void onClick(View v) {Intent cSwitchIntent = new Intent();if(null != cSwitchIntent){cSwitchIntent.setClass(Changshahome.this, SwitchMulActivityActivity.class);startActivity(cSwitchIntent);//Changshahome.this.finish();}}}); cbtGoShanghai.setOnClickListener(new Button.OnClickListener() {//实现监听器接口的匿名内部类,其中监听器本身是View类的内部接口//实现接口必须实现的onClick方法@Overridepublic void onClick(View v) {Intent cSwitchIntent = new Intent();if(null != cSwitchIntent){cSwitchIntent.setClass(Changshahome.this, Shanghaihome.class);startActivity(cSwitchIntent);//Changshahome.this.finish();}}}); }while(false);}}
Shanghaihome.java
package lostman.rigortek.china;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.Button;public class Shanghaihome extends Activity {private Button cbtGoBasehome;private Button cbtGoShanghai;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.shanghaihome);cbtGoBasehome = (Button) findViewById(R.id.gobasehome); cbtGoShanghai = (Button) findViewById(R.id.gochangsha); do{ if(null == cbtGoBasehome || null == cbtGoShanghai){ break; } cbtGoBasehome.setOnClickListener(new Button.OnClickListener() {//实现监听器接口的匿名内部类,其中监听器本身是View类的内部接口//实现接口必须实现的onClick方法@Overridepublic void onClick(View v) {Intent cSwitchIntent = new Intent();if(null != cSwitchIntent){cSwitchIntent.setClass(Shanghaihome.this, SwitchMulActivityActivity.class);startActivity(cSwitchIntent);//Shanghaihome.this.finish();}}}); cbtGoShanghai.setOnClickListener(new Button.OnClickListener() {//实现监听器接口的匿名内部类,其中监听器本身是View类的内部接口//实现接口必须实现的onClick方法@Overridepublic void onClick(View v) {Intent cSwitchIntent = new Intent();if(null != cSwitchIntent){cSwitchIntent.setClass(Shanghaihome.this, Changshahome.class);startActivity(cSwitchIntent);//Shanghaihome.this.finish();}}}); }while(false);}}
main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#ff0000" android:background="#ffffff" android:textSize="20dp" android:text="@string/Basehome" android:gravity="center"/> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:layout_marginTop="10dp" > <Button android:id="@+id/gochangsha" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/SwitchToChangshahome" android:layout_weight="1" android:layout_marginLeft="20dp" android:layout_marginRight="10dp"/> <Button android:id="@+id/goshanghai" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/SwitchToShanghaihome" android:layout_weight="1" android:layout_marginLeft="10dp" android:layout_marginRight="20dp"/></LinearLayout></LinearLayout>
changshahome.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#00ff00" android:background="#ffffff" android:textSize="20dip" android:text="@string/Changsha" android:gravity="center"/> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:layout_marginTop="10dp" > <Button android:id="@+id/gobasehome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/SwitchToBasehome" android:layout_weight="1" android:layout_marginLeft="20dp" android:layout_marginRight="10dp"/> <Button android:id="@+id/goshanghai" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/SwitchToShanghaihome" android:layout_weight="1" android:layout_marginLeft="10dp" android:layout_marginRight="20dp"/></LinearLayout></LinearLayout>
shanghaihome.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#0000ff" android:background="#ffffff" android:textSize="20dip" android:text="@string/Shanghai" android:gravity="center"/> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:layout_marginTop="10dp" > <Button android:id="@+id/gobasehome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/SwitchToBasehome" android:layout_weight="1" android:layout_marginLeft="20dp" android:layout_marginRight="10dp"/> <Button android:id="@+id/gochangsha" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/SwitchToChangshahome" android:layout_weight="1" android:layout_marginLeft="10dp" android:layout_marginRight="20dp"/></LinearLayout> </LinearLayout>
2)效果图:
参考:Android开发循序渐进实例1--资源文件设计以及画面跳转例子
http://blog.csdn.net/jackxinxu2100/article/details/5257186
Activity的跳转与传值
http://android.blog.51cto.com/268543/323982
- android之activity跳转 窗口跳转
- Android之Activity跳转
- Android之Activity跳转
- Android入门之Activity跳转
- Android之Activity跳转方式
- Android之Activity之回顾跳转动画
- android之两个activity相互跳转
- Android开发之——activity跳转
- AndroidのActivity之回顾跳转动画
- AndroidのActivity之回顾跳转动画
- Android之activity跳转并且回调
- Android基础篇之Activity跳转
- Android控件之TextView实现Activity跳转
- AndroidのActivity之回顾跳转动画
- android之 Activity跳转出现闪屏
- Android 控件之点击链接跳转Activity
- Android之跳转(普通类到Activity)
- Android之Activity跳转动画--左右切换
- Windows 2003路由设置
- ajax技术核心
- 十四周任务2
- Windows server 2003 IP路由配置
- 用 C++ 创建简单的 Win32 服务程序
- android之activity跳转 窗口跳转
- 知识的诅咒与背景植入
- 关于Linux下串口通信的一点心得
- 系统管理类命令
- 复变函数与积分变换-----基础总结一
- 另一种角度来看待zookeeper
- 常用正则表达式大全!(例如:匹配中文、匹配html)
- DSP/BIOS与main()函数关系
- 识的诅咒