【android开发】页面之间的跳转和传值
来源:互联网 发布:4g流量3g网络可以用吗 编辑:程序博客网 时间:2024/06/05 07:28
页面之前的跳转和传值需要两个以上的页面,所以在项目中你需要配置相应的activity和相应的处理类
AndroidManifest.xml中的配置
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".onTwoActivity" android:label="用户登录" android:theme="@android:style/Theme" > </activity> </application>
添加相应的处理类.java(需要继承Activity)
public class onTwoActivity extends Activity { public onTwoActivity() {// TODO Auto-generated constructor stub}@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.ontwo);//关联相对应的界面配置文件}}简单的跳转
Intent intent=new Intent(MainActivity.this,onTwoActivity.class); startActivity(intent);
或者
Intent intent=new Intent(); intent.setClass(MainActivity.this, onTwoActivity.class); startActivity(intent);
页面之间的传值
Intent intent=new Intent(); intent.setClass(MainActivity.this, onTwoActivity.class); Bundle bundle=new Bundle(); bundle.putString("name", "value"); bundle.putBoolean("name2", true); intent.putExtras(bundle); //intent.putExtra("Name", "内容");//如果传递的值内容较少,可以直接使用此方法传值 startActivity(intent);
B页面接收A页面传过来的值
//获取Intent中的Bundle对象Bundle bundle=this.getIntent().getExtras();//获取bundle中的数据,分数据类型String sname=bundle.getString("name");Boolean bname=bundle.getBoolean("name2");
0 0
- 【android开发】页面之间的跳转和传值
- android开发中页面之间跳转的传值问题
- html 页面之间跳转和传值
- html 页面之间跳转和传值
- Android开发笔记--Activity 页面跳转和传值
- html 页面之间跳转和传值
- 客户端跳转 和 服务器端跳转 页面之间的数据传递
- Android混合开发之Activity类与html页面之间的相互跳转
- Android混合开发之Activity类与html页面之间的相互跳转之PhoneGap
- Android开发:页面跳转和数据传递
- IOS 页面之间的跳转以及传值
- react页面之间的跳转及传值
- Android开发 两个Activity之间通过Intent跳转传值
- HTML页面之间跳转传值
- android页面的跳转以及传值
- android intent的跳转,页面传值
- 网站开发中,在页面之间的跳转
- Android开发--页面间的跳转
- HDU 1159 LCS
- 解决ubuntu12.04下Haproxy不启动的问题
- linux 命令行操作(一)
- 银河护卫队高清 hd在线观看
- Unity3d UnityEditor EditorWindow 自定义窗体控件
- 【android开发】页面之间的跳转和传值
- Windows——获取CPU ID命令(备忘)
- free buffer waits
- 中国地区的官方Ubuntu源
- matlab meshgrid
- 哈哈哈哈哈
- Maven的安装、配置及使用入门
- Django 中的用户认证 2014
- 毕向东java基础笔记