一个项目里面可以有多个Activity

AndroidManifest.xml
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> 在谁的里面就运行谁
在两个Activity 里切换

package com.example.chapter31;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button; public class MainActivity extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i("Activity1","onCreate");
Button button =(Button)findViewById(R.id.button);
button.setOnClickListener (new View.OnClickListener(){
@Override
public void onClick (View view){
Intent intent = new Intent (MainActivity.this,SecondActivity.class);
startActivity(intent);
}});
}
@Override
protected void onStart() {
super.onStart();
Log.i("Activity1","onStart()");
}
@Override
protected void onRestart() {
super.onRestart();
Log.i("Activity1","onRestart()");
}
@Override
protected void onResume() {
super.onResume();
Log.i("Activity1","onResume()");
}
@Override
protected void onPause() {
super.onPause();
Log.i("Activity1","onPause()");
}
@Override
protected void onStop() {
super.onStop();
Log.i("Activity1","onStop()");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i("Activity1","onDestroy()");
}
} <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id = "@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight = ""
android:text = "跳转到第二个Activity" /> </LinearLayout> package com.example.chapter31;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button; public class SecondActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout1);
Log.i("Activity1","onCreate");
Button button = (Button)findViewById(R.id.button);
button.setOnClickListener (new View.OnClickListener(){
@Override
public void onClick (View view){
Intent intent = new Intent (SecondActivity.this,MainActivity.class);
从2到1
startActivity(intent);
}});
}
@Override
protected void onStart() {
super.onStart();
Log.i("Activity2","onStart()");
}
@Override
protected void onRestart() {
super.onRestart();
Log.i("Activity2","onRestart()");
}
@Override
protected void onResume() {
super.onResume();
Log.i("Activity2","onResume()");
}
@Override
protected void onPause() {
super.onPause();
Log.i("Activity2","onPause()");
}
@Override
protected void onStop() {
super.onStop();
Log.i("Activity2","onStop()");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i("Activity2","onDestroy()");
}
} <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SecondActivity">
<Button
android:id = "@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight = ""
android:text = "跳转到Activity1" /> </LinearLayout> 别忘了在AndroidManifest 里面注册

U3的更多相关文章

  1. UC手机浏览器(U3内核)相关文档整理

    Note:绝大多数API在IOS版下不支持,使用前请自行测试. UC官方的开发者中心:http://www.uc.cn/business/developer.shtml U3内核定制<meta& ...

  2. 闪迪U3利用工具U3-Pwn

    闪迪U3利用工具U3-Pwn   闪迪U3是闪迪公司为Sandisk Cruzer系列U盘提供的一个功能.该模块支持数据加密和CD启动功能.U3-Pwn就是针对U3的一个利用工具.渗透测试人员可以通过 ...

  3. 买SD卡和TF卡要买U3和A2协议的

    A3 最低平稳写入30M/s

  4. win8.1硬盘安装ubuntu14.04双系统

    在网上找了很多方法都失败了,原因是大多数方法都是用mbr方式安装的,如grub4dos,easybcd.以至于连自己都怀疑win8能不能用硬盘安装,差点就去买个u盘来安装了,就在打算放弃的时候在ubu ...

  5. 前端自动化构建工具gulp记录

    一.安装 1)安装nodejs 通过nodejs的npm安装gulp,插件也可以通过npm安装.windows系统是个.msi工具,只要一直下一步即可,软件会自动在写入环境变量中,这样就能在cmd命令 ...

  6. java web学习总结(五) -------------------servlet开发(一)

    一.Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术. Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个Java程序向 ...

  7. Android Studio开发RecyclerView遇到的各种问题以及解决(一)

    以前一直在用ListView,,,最近才看RecyclerView发现好强大.RecyclerView前提是Android版本在5.0以上,本人以前用的是eclipse只支持到4.4.索性就安装一个A ...

  8. liunx 磁盘管理命令记录

    Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...

  9. centos6.3与jexus5.4.4配置支持php(wordpress)

    centos6.3与jexus5.4.4配置支持php,并搭建自己的wordpress博客,供那些在Linux平台下想让 php和asp.net一起跑的初学者参考. 1.搭建webserver 首先准 ...

随机推荐

  1. Quartz.NET 作业调度使用

    Quartz.NET的使用方法有很多,今天使用Quartz.NET3.0.6的时候发现和2.0版本的语法不太一样,百度上找了一圈也没有找到解决办法 后来在GitHub上下载源代码解决了 实现每隔10s ...

  2. mongoDB--万能的$关键字

    之前哥的博客写了增删改查的基本用法,其中$set是关键字用来修改值的,但是不关只有set这一个关键字,下面我们就来说一个万能的$关键字 1.常见的等于 大于 小于 大于等于 小于等于 #等于---&g ...

  3. SpringBoot | 第三十章:Spring-data-jpa的集成和使用

    前言 在前面的第九章:Mybatis-plus的集成和使用章节中,介绍了使用ORM框架mybatis-plus进行数据库的访问.今天,我们来简单学习下如何使用spring-data-jpa进行数据库的 ...

  4. linux shell内置判断

    内置判断,成功的时候返回0,不成功返回非零 test  判断表达式 [ 判断表达式 ]       注意前后必须留空格哦 数值运算 -eq   等于 -ne   不等于 -gt     大于 -ge ...

  5. stark——pop功能(admin中添加功能)

    一.pop功能需要实现的功能和问题 1.如何在一对多和多对多字段后渲染 +2.+对应的跳转路径是什么3.保存添加记录同时,将原页面的对应的下拉菜单中添加该记录 二.window.open()方法详解 ...

  6. cordova 开发 android app 简要流程

    1. 安装cordova:npm install -g cordova --registry=https://registry.npm.taobao.org 2. 创建cordova工程:进入工作目录 ...

  7. iPython与notebook的基本用法

    1 Ipython 安装 pip install ipython 2 Notebooke 基本用法 启动ipython使用ipython 启动notebook 使用 ipython notebook ...

  8. 通过 Powershell 来替换 ARM 模式下虚拟机的网络接口

    需求描述 客户在部署完 ARM 模式的虚拟机以后,由于误操作在虚拟机内部禁用了网卡导致远程访问虚拟机受到限制,以下是通过 Powershell 命令来替换原有虚拟网络接口实现虚拟网卡重置功能. Not ...

  9. java:网络通讯

    网络标准模型:开放式系统模型OSI https://www.cnblogs.com/lydit/articles/4499928.html 理解Scoket通讯:https://www.cnblogs ...

  10. 架构蓝图--软件架构 "4+1" 视图模型

    引言 我们已经看到在许多文章和书籍中,作者欲使用单张视图来捕捉所有的系统架构要点.通过仔细地观察这 些图例中的方框和箭头,不难发现作者努力地在单一视图中表达超过其表达限度的蓝图.方框是代表运行的程序吗 ...