@String 支持多语言

layout中的text文本中String都尽量定义在String.xml中,便于多语言管理。

<resources>
<string name="app_name">HelloWorld</string>
<string name="action_settings">Settings</string>
<string name="text1">hello,you are the best!</string>
<string name="btn1">Jump to Another Activity</string>
<string name="title_activity_another">AnotherActivity</string>
</resources>

跳转另一个actvity

①监控点击动作可以有两种方式:

    1> 在layout中设置Button onclick属性为方法名,在activity里编写方法

    2> 在activity里findViewbyID 找到Button控件 ,设置监听事件

 
如采取第一种方法,要注意:

note that, in order for the system to match this method to the method name given to android:onClick, the signature must be exactly as shown. Specifically, the method must:

  • Be public
  • Have a void return value
  • Have a View as the only parameter (this will be the View that was clicked)

android:onClick="send"

public void send(View view){

    Intent intent = new Intent(this,AnotherActivity.class);
startActivity(intent); }

跳转网页

public void sendToBrowser(View view){

    startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.baidu.com")));
}

activity的生命周期&activity跳转时的生命周期

通过在代码中activity每个生命周期中添加system.out,了解activity生命周期

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("A onCreate");
} protected void onStart() {
super.onStart();
System.out.println("A onStart");
} protected void onResume() {
super.onResume();
System.out.println("A onResume");
} ..
..
.. 在两个activity跳转的过程中,上一个activity如果不可见,则先执行onPause(),再执行onStop()
如果该activity仍可见(比如下一个activity是dialogue,则只执行onPause(),关闭dialogue直接执行onResume()) 将activity设为dialogue的方法,在manifest文件中修改:
<activity
android:name=".AnotherActivity"
android:label="@string/title_activity_another"
android:theme="@style/Base.Theme.AppCompat.Dialog">
</activity>

Android-1的更多相关文章

  1. 【原】Android热更新开源项目Tinker源码解析系列之三:so热更新

    本系列将从以下三个方面对Tinker进行源码解析: Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Android热更新开源项目Tinker源码解析系列之二:资源文件热更新 A ...

  2. 配置android sdk 环境

    1:下载adnroid sdk安装包 官方下载地址无法打开,没有vpn,使用下面这个地址下载,地址:http://www.android-studio.org/

  3. Android SwipeRefreshLayout 下拉刷新——Hi_博客 Android App 开发笔记

    以前写下拉刷新 感觉好费劲,要判断ListView是否滚到顶部,还要加载头布局,还要控制 头布局的状态,等等一大堆.感觉麻烦死了.今天学习了SwipeRefreshLayout 的用法,来分享一下,有 ...

  4. Android Studio配置 AndroidAnnotations——Hi_博客 Android App 开发笔记

    以前用Eclicps 用习惯了现在 想学学 用Android Studio 两天的钻研终于 在我电脑上装了一个Android Studio 并完成了AndroidAnnotations 的配置. An ...

  5. Android请求网络共通类——Hi_博客 Android App 开发笔记

    今天 ,来分享一下 ,一个博客App的开发过程,以前也没开发过这种类型App 的经验,求大神们轻点喷. 首先我们要创建一个Andriod 项目 因为要从网络请求数据所以我们先来一个请求网络的共通类. ...

  6. 【原】Android热更新开源项目Tinker源码解析系列之一:Dex热更新

    [原]Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Tinker是微信的第一个开源项目,主要用于安卓应用bug的热修复和功能的迭代. Tinker github地址:http ...

  7. 【原】Android热更新开源项目Tinker源码解析系列之二:资源文件热更新

    上一篇文章介绍了Dex文件的热更新流程,本文将会分析Tinker中对资源文件的热更新流程. 同Dex,资源文件的热更新同样包括三个部分:资源补丁生成,资源补丁合成及资源补丁加载. 本系列将从以下三个方 ...

  8. Android Studio 多个编译环境配置 多渠道打包 APK输出配置

    看完这篇你学到什么: 熟悉gradle的构建配置 熟悉代码构建环境的目录结构,你知道的不仅仅是只有src/main 开发.生成环境等等环境可以任意切换打包 多渠道打包 APK输出文件配置 需求 一般我 ...

  9. JS调用Android、Ios原生控件

    在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...

  10. Android UI体验之全屏沉浸式透明状态栏效果

    前言: Android 4.4之后谷歌提供了沉浸式全屏体验, 在沉浸式全屏模式下, 状态栏. 虚拟按键动态隐藏, 应用可以使用完整的屏幕空间, 按照 Google 的说法, 给用户一种 身临其境 的体 ...

随机推荐

  1. cf B. Vasya and Public Transport

    http://codeforces.com/contest/355/problem/B #include <cstdio> #include <cstring> #includ ...

  2. poj 3792 Area of Polycubes

    http://poj.org/problem?id=3792 #include <cstdio> #include <cstring> #include <cmath&g ...

  3. IIC总线协议---以存储芯片at24c64为例

    IIC总线协议 前言:年前给老师做个红外抄表系统,,现在对当中用到的一些模块总结一下. 1.只有在总线空闲时才允许启动数据传送. 2.在数据传送过程中,当时钟线为高电平时,数据线必须保持稳定状态,不允 ...

  4. (转) Linux的capability深入分析(2)

    一)capability的工具介绍   在我们的试验环境是RHEL6,libcap-2.16软件包中包含了相关的capability设置及查看工作,如下:   rpm -ql libcap-2.16- ...

  5. 符号表实现(Symbol Table Implementations)

    符号表的实现有很多方式,下面介绍其中的几种. 乱序(未排序)数组实现 这种情况,不需要改变数组,操作就在这个数组上执行.在最坏的情况下插入,搜索,删除时间复杂度为O(n). 有序(已排序)数组实现 这 ...

  6. Display number of replies in disscussion board

    how to display number of replies in disscussion board I have a require about display the replies' nu ...

  7. javascript笔记7之对象数组

    /* var box = new Array(); //声明一个数组,空数组 alert(typeof box); //数组属于object类型 var box = new Array('李炎恢', ...

  8. 解决IE6下DIV无法实现1px高度问题

    2.多加一个line-height:1px的属性,不过得在DIV里多加一个 ,也就是空格,以下为引用的内容: <styletypestyletype="text/css"&g ...

  9. MVVM架构~knockoutjs系列之表单添加(验证)与列表操作源码开放

    返回目录 本文章应该是knockoutjs系列的最后一篇了,前几篇中主要讲一些基础知识,这一讲主要是一个实际的例子,对于一个对象的添加与编辑功能的实现,并将项目源代码公开了,共大家一起学习! knoc ...

  10. spring-data-mongodb必须了解的操作

    http://docs.spring.io/spring-data/data-mongo/docs/1.0.0.M5/api/org/springframework/data/mongodb/core ...