manifests里的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.chenshuai.test"> <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--谁在前启动谁-->
<activity android:name=".Axtivity2">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </activity> <activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </application> </manifest>

layout里新建的layoutactivity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"> <!--匹配父窗口 match_parent
包裹内容 wrap_content-->
<TextClock
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="大家好" /> </LinearLayout>

layout里MainActivity

package com.hanqi.text3;

import android.app.Activity;
import android.os.Bundle;
//继承了Activity
public class MainActivity extends Activity { @Override //覆盖 重写了父类的onCreate()
protected void onCreate(Bundle savedInstanceState) {
//super 父类
//调用了父类的方法
super.onCreate(savedInstanceState);
//设置Java代码和layout文件的关联
//通过R文件的id值
setContentView(R.layout.activity_main);
}
}

java里新建的Activity2

package com.example.chenshuai.test;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log; /**
* Created by chenshuai on 2016/3/16.
*/
public class Axtivity2 extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layoutactivity); System.out.println("这是我运行的第一个Activity"); //输出日志
Log.d("test","Log输出的信息"); Log.w("test","Log输出的信息");//warning 蓝色 Log.e("test","Log输出的信息");//eror 红色 Log.i("test","Log输出的信息"); Log.v("test","Log输出的信息"); }
}

Android——Activity练习的更多相关文章

  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. webui-popover 一个轻量级的jquery弹出层插件

    该提示框插件可以和Bootstrap完美结合,但是并不一定需要和Bootstrap一起使用.它支持IE7以上的浏览器. 首先要引入需要的css  js  文件 <link rel="s ...

  2. python基础学习 Day19 面向对象的三大特性之多态、封装 property的用法(1)

    一.课前内容回顾 继承作用:提高代码的重用性(要继承父类的子类都实现相同的方法:抽象类.接口) 继承解释:当你开始编写两个类的时候,出现了重复的代码,通过继承来简化代码,把重复的代码放在父类中. 单继 ...

  3. Tween animation

    [Tween animation] An animation defined in XML that performs transitions such as rotating, fading, mo ...

  4. EF CodeFirst学习笔记003--如何创建表

    参考: http://www.cnblogs.com/Wayou/archive/2012/09/20/EF_CodeFirst.html webconfig中修改: <connectionSt ...

  5. 调整数组顺序使奇数位于偶数前面(python)

    题目描述 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变. # -*- codi ...

  6. python基础入门学习简单程序练习

    1.简单的乘法程序 i = 256*256 print('The value of i is', i) 运行结果: The value of i is 65536 2.执行python脚本的两种方式 ...

  7. 有关ngui grid中去除一项后的排序问题

    遇到这个问题,是在实现一个公告栏界面的时候,公告栏可以新增一条公告,也可以删除一条公告. 新增很简单,这里不做多的介绍: 关于删除,之前的代码是: GameObject go = is_parent. ...

  8. 三个<li>元素放一行

    <ul><li style="float:left;display:inline;">0</li><li style="floa ...

  9. Codeforces Beta Round #35 (Div. 2)

    Codeforces Beta Round #35 (Div. 2) http://codeforces.com/contest/35 A 这场的输入输出是到文件中的,不是标准的输入输出...没注意看 ...

  10. ECMAScript6的原型

    class Car { constructor(name){ this.name = name; } getName(){ } } class Ferrari extends Car{ constru ...