跳转,顾名思义,是从一个界面跳到另一个界面,是用intent(意图)来进行操作,主要是解决Android应用的各项组件之间的通
讯,过程中可以携带数据。
跳转分两种:显示跳转和隐式跳转。
下面进行跳转,创建一个android项目,要实现一个功能,给定两个按钮,点击第一个实现显示跳转,点击第二个实现。
隐式跳转。
效果图:
显示跳转:
隐式跳转:
下面来看看怎么实现:
在activity_main中添加两个按钮:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.tz01.MainActivity" >
<Button
android:id="@+id/bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击显示跳转"
/>
<Button
android:id="@+id/bt1"
android:layout_toRightOf="@id/bt"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击隐式跳转"
/>
</RelativeLayout>
之后部署显示和隐式跳转页面的内容,先创建两个android xml,里面布局自己要的控件,我这里面只有一个textview,
显示xml:
<?xml version="1.0" encoding="utf-8"?>
<Li