接着Android-Activity使用(1)实现页面跳转

一.在main_activity中添加按钮,注意 id的写法为"@+id/"+"id真正的名字"

    <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start_Aty1"
android:id="@+id/btnStartAty1"
android:layout_below="@+id/tvOut"
android:layout_alignParentStart="true"/>

二.在MainActivity.java中实现实现跳转

private Button btnSatrtAty1;

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); //必须放在setContentView之后
btnSatrtAty1=(Button)findViewById(R.id.btnStartAty1);
//给按钮设定事件监听器
btnSatrtAty1.setOnClickListener(
//实现OnClickListener接口的了匿名类
new View.OnClickListener() {
@Override
public void onClick(View view) {
//事件中启动Aty1
//参数一:MainActivity 的实例
//参数二:要启动的Activity的类的定义为Class类型
//this 指实现OnClickListener的内部类
Intent i=new Intent(MainActivity.this,Aty1.class);
startActivity(i);
}
});
}

三、实现页面的关闭

直接调用 方法 finish();

Android-Activity使用(2)的更多相关文章

  1. Android:Activity+Fragment及它们之间的数据交换.

    Android:Activity+Fragment及它们之间的数据交换 关于Fragment与Fragment.Activity通信的四种方式 比较好一点的Activity+Fragment及它们之间 ...

  2. Android Activity launchMode研究

    Android Activity launchMode研究 Activity的Launch mode一共有四种: standard, singleTop, singleTask, singleInst ...

  3. android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别

    android Activity类中的finish().onDestory()和System.exit(0) 三者的区别 Activity.finish() Call this when your a ...

  4. Android Activity的生命周期简单总结

    Android Activity的生命周期简单总结 这里的内容参考官方的文档,这篇文章的目的不是去总结Activity是如何启动,如何创造,以及暂停和销毁的,而是从实际开发中分析在Activity各个 ...

  5. Android Activity返回键控制的两种方式

    Android Activity返回键监听的两种方式 1.覆写Activity的OnBackPressed方法 官方解释: Called when the activity has detected ...

  6. Android Activity和Fragment的转场动画

    Android Activity和Fragment的转场动画 Activity转场动画 Activity的转场动画是通过overridePendingTransition(int enterAnim, ...

  7. android Activity生命周期(设备旋转、数据恢复等)与启动模式

    1.Activity生命周期     接下来将介绍 Android Activity(四大组件之一) 的生命周期, 包含运行.暂停和停止三种状态,onCreate.onStart.onResume.o ...

  8. Android Activity的加载模式和onActivityResult方法之间的冲突

    前言 今天在调试程序时,发现在某一Activity上点击返回键会调用该Activity的onActivityResult()方法.我一开始用log,后来用断点跟踪调试半天,还是百思不得其解.因为之前其 ...

  9. Android Activity的onSaveInstanceState() 和 onRestoreInstanceState()方法:

    Android Activity的onSaveInstanceState() 和 onRestoreInstanceState()方法: 1. 基本作用: Activity的 onSaveInstan ...

  10. Android activity的回传数据

    package com.example.myact3; import android.content.Intent; import android.os.Bundle; import android. ...

随机推荐

  1. HDU 3078 (LCA+树链第K大)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3078 题目大意:定点修改.查询树中任意一条树链上,第K大值. 解题思路: 先用离线Tarjan把每个 ...

  2. IOS学习笔记25—HTTP操作之ASIHTTPRequest

    IOS学习笔记25—HTTP操作之ASIHTTPRequest 分类: iOS2012-08-12 10:04 7734人阅读 评论(3) 收藏 举报 iosios5网络wrapper框架新浪微博 A ...

  3. InterBase数据库迁移到MySQL(说明)

    刚刚到公司1周便接到了第一个需求,进过了几天的沟通明白了是从gbk文件中恢复InterBase数据库,然后再将恢复到数据库中的数据导出到远程的MySQL数据库中,拿到需求先分步去看问题了,问题大致可分 ...

  4. C++ string 类的 find 方法实例详解

    1.C++ 中 string 类的 find 方法列表 size_type std::basic_string::find(const basic_string &__str, size_ty ...

  5. 关于IAP的破解

    介绍 大概在今年7月份,有俄罗斯黑客破解了苹果的应用内付费(In-App Purchases),设备在不越狱的情况下就可以免费获得来自苹果官网App Store里应用的收费道具.受影响的产品众多,包括 ...

  6. 【LeetCode】16. 4Sum

    题目:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = ...

  7. jQuery设计思想之取值和赋值

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. ArcGIS 使用点滴记录

    (1)ArcGIS Shapefile数据text类型字段最长为254.若想更长,使用GeoDatabase (2)ArcGIS中出现一些奇奇怪怪的问题,找不到解决方法时,一般考虑是不是空间参考的问题 ...

  9. 2016HUAS暑假集训训练2 O - Can you find it?

    题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/O 这道题是一道典型二分搜素题,题意是给定3个数组 每个数组的数有m个 再给定l个s ...

  10. Cocos2d-x 3.4环境安装

    电脑系统window7 32位 1.首先从官网下载cocos2d-x并解压 http://cn.cocos2d-x.org/download/ 解压后的文件夹中有一个setup.py,双击运行.需要安 ...