不管是在APP,还是在网站中,页面之间的跳转都是很常见的,本文主要讲一下在APP中,如何通过Intent实现页面的跳转。

不带参数:

写在MainActivity页面的代码:

 Intent intent = new Intent();
intent.setClass(MainActivity.this, LoginActivity.class);//从MainActivity页面跳转至LoginActivity页面
this.startActivity(intent);

带参数:

写在SpendingActivity页面的代码:

 Intent intent=new Intent(SpendingActivity.this,ExpenseProcesActivity.class);//从SpendingActivity页面跳转至ExpenseProcesActivity页面
intent.putExtra("strType", 0);//参数:name、value
SpendingActivity.this.startActivity(intent);

写在ExpenseProcesActivity接收页面的代码:

 private int type = 0;

 //接收传递过来的参数
final Intent intent = getIntent();
type = intent.getIntExtra("strType", 0);

备注:

可传递的参数有多种类型,在接收参数的时候,也要根据传入类型,选用对应的接收函数

传递参数的类型,Eg:

对应的接收函数,Eg:

Android Studio 使用Intent实现页面的跳转(带参数)的更多相关文章

  1. Android Intent实现页面之间跳转

    什么是IntentIntent可以理解为信使(意图)由Intent来协助完成Android各个组件之间的通讯Intent实现页面逐渐的跳转1.startActivity(inetnt)2.startA ...

  2. js获得页面get跳转的参数

    通过js获得页面跳转参数 页面通过window.location.href或通过window.parent.location.href进行页面跳转,在新的页面如何获得相应的参数呢? window.lo ...

  3. Android笔记-4-实现登陆页面并跳转和简单的注册页面

    实现登陆页面并跳转和简单的注册页面   首先我们来看看布局的xml代码 login.xml <span style="font-family:Arial;font-size:18px; ...

  4. 教会你彻底解决android studio c/c++ jni代码无法跳转

    时不时总会遇到原来c c++ jni代码跳转很欢乐,突然也不知道咋滴了build也能build成功,运行也能正常运行,就是代码不能跳转了,首先来科普下一些背景知识. 如果让代码跳转起来,大概需要做哪些 ...

  5. 关于页面的跳转添加参数(比如id啥的)

    最近一些新手老是问我一些关于页面之间的传递跳转,怎么带参数这件事,(比如说一个列表页到详情页面数据是怎么传输的),今个没事就在这说一些! 这里拿列表页面到详情页面来阐述下哈! 首先在列表页,我们通过a ...

  6. Android程序启动程序与页面的跳转

    package login; import com.example.login.R; import android.app.Activity; import android.content.Inten ...

  7. android studio创建一个最简单的跳转activity

    实现目的:由mainActivity跳转到otherActivity 1.写好两个layout文件,activity_main.xml和otherxml.xml activity_main.xml & ...

  8. Android Studio 使用Intent

    1.显式Intent Intent intent=new Intent(yzj.this,MainActivity.class);//当前活动的实例,要去的实例 startActivity(inten ...

  9. android studio实现Intent通信-------牛刀小试

    概述: 本博文实现一种小程序,两个Activity单向通信,主从关系,MainActivty 页面布局一个EditText+Button,实现逻辑是单击按钮将信息发送给另外一个DisplayMessa ...

随机推荐

  1. Android学习之一

  2. [webpack]path、publicPath、--content-base 理解

    附源码:http://files.cnblogs.com/files/chenshao/startPublic.rar 'use strict'; var webpack = require('web ...

  3. 记一次Socket编程踩的坑

    闲来无事研究了下Socket,想用它做个简单的聊天室模型,结果踩了个坑,整半天才出来,惭愧啊,先上完成的代码吧 服务端: public partial class Form1 : Form { pub ...

  4. 【数组】Container With Most Water

    题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...

  5. PullToRefreshListView 进入界面不能立即显示刷新控件的bug 解决方案

    1.首先定位到PullToRefreshListView.java这个文件 2.找到onRefreshing(final boolean doScroll)方法 @Override protected ...

  6. java-多线程future等待返回

    多线程中需要返回值, java中有个fork/join模型, 没有细研究, 简单实用callable进行了返回 Thread1 package com.iwhere.easy.travel.test. ...

  7. elasticsearch插件安装之--拼音插件

    /** * vm12下的centos7.2 * elasticsearch 5.2.2 */ 有时在淘宝搜索商品的时候, 会发现使用汉字, 拼音, 或者拼音混合汉字都会出来想要的搜索结果, 今天找了一 ...

  8. android studio启动和项目编译问题

    第一次安装完成后,不要立刻启动,首先在Android Studio安装目录下的 bin 目录下,找到 idea.properties 文件,在文件最后追加disable.android.first.r ...

  9. Java并发编程笔记之ThreadLocalRandom源码分析

    JDK 并发包中 ThreadLocalRandom 类原理剖析,经常使用的随机数生成器 Random 类的原理是什么?及其局限性是什么?ThreadLocalRandom 是如何利用 ThreadL ...

  10. 关于post跨域请求数据的问题-包括同源策略

    在<system.webServer>配置下面加入 <httpProtocol> <customHeaders> <add name="Access ...