U3
一个项目里面可以有多个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的更多相关文章
- UC手机浏览器(U3内核)相关文档整理
Note:绝大多数API在IOS版下不支持,使用前请自行测试. UC官方的开发者中心:http://www.uc.cn/business/developer.shtml U3内核定制<meta& ...
- 闪迪U3利用工具U3-Pwn
闪迪U3利用工具U3-Pwn 闪迪U3是闪迪公司为Sandisk Cruzer系列U盘提供的一个功能.该模块支持数据加密和CD启动功能.U3-Pwn就是针对U3的一个利用工具.渗透测试人员可以通过 ...
- 买SD卡和TF卡要买U3和A2协议的
A3 最低平稳写入30M/s
- win8.1硬盘安装ubuntu14.04双系统
在网上找了很多方法都失败了,原因是大多数方法都是用mbr方式安装的,如grub4dos,easybcd.以至于连自己都怀疑win8能不能用硬盘安装,差点就去买个u盘来安装了,就在打算放弃的时候在ubu ...
- 前端自动化构建工具gulp记录
一.安装 1)安装nodejs 通过nodejs的npm安装gulp,插件也可以通过npm安装.windows系统是个.msi工具,只要一直下一步即可,软件会自动在写入环境变量中,这样就能在cmd命令 ...
- java web学习总结(五) -------------------servlet开发(一)
一.Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术. Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个Java程序向 ...
- Android Studio开发RecyclerView遇到的各种问题以及解决(一)
以前一直在用ListView,,,最近才看RecyclerView发现好强大.RecyclerView前提是Android版本在5.0以上,本人以前用的是eclipse只支持到4.4.索性就安装一个A ...
- liunx 磁盘管理命令记录
Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...
- centos6.3与jexus5.4.4配置支持php(wordpress)
centos6.3与jexus5.4.4配置支持php,并搭建自己的wordpress博客,供那些在Linux平台下想让 php和asp.net一起跑的初学者参考. 1.搭建webserver 首先准 ...
随机推荐
- PIXI 宝物猎人(7)
介绍 ,本实例来自官网 代码结构 打开 treasureHunter.html 文件,你将会看到所有的代码都在一个大的文件里.下面是一个关于如何组织所有代码的概览: //Setup Pixi and ...
- Docker的安装和镜像管理并利用Docker容器实现nginx的负载均衡、动静分离
Docker的安装 一.Docker的概念 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化 ...
- os.popen('python hello_out.py')中Python程序执行时默认的当前路径为MS-DOS CMD的默认路径
>>> import os >>> os.getcwd() 'D:\\pythonCode\\pp4e' >>> os.chdir('Stream ...
- Oracle 系统常用命令
1.基本口令 1.1.show user 作用:显示当前连接用户 1.2.conn 用户名/密码 ...
- TOJ 1840 Jack Straws
Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped ...
- log4j 2整理
# Log4j 2最佳实践 #Log4j的1.x版本已经被广泛使用于很多应用程序中.然而,它这些年的发展已经放缓.它变得越来越难以维护,因为它需要严格遵循很老的Java版本,并在2015年8月寿终正寝 ...
- 操作系统管理CPU的直观想法
CPU的工作原理 要想管理CPU,就要先学会如何使用CPU.我们先从一个程序的执行来看看CPU是如何工作的. void main(){ int i , sum; ; i < ; i++){ su ...
- mvc路由引起异步调用web服务的问题
从一篇blog得知使用脚本可以异步调用Web服务,觉得很新鲜,因为自己很少用到Web服务,所以决定写一写看看什么效果. 首先在UI项目(我使用的是MVC4.0)里创建一个Web服务. 添加Web服务后 ...
- [LeetCode]23. Merge k Sorted Lists合并K个排序链表
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. E ...
- Jquery系列:设置div、span等dom结点的内容,jquery中没有innerText、innerHtml
发现如果我在div或者其他非表单的标签中赋值,原本用普通的js就直接document.getElementById("id").innerHtml(或者其他几个)就可以了. 但是在 ...