Android——Activity练习
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练习的更多相关文章
- Android:Activity+Fragment及它们之间的数据交换.
Android:Activity+Fragment及它们之间的数据交换 关于Fragment与Fragment.Activity通信的四种方式 比较好一点的Activity+Fragment及它们之间 ...
- Android Activity launchMode研究
Android Activity launchMode研究 Activity的Launch mode一共有四种: standard, singleTop, singleTask, singleInst ...
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
android Activity类中的finish().onDestory()和System.exit(0) 三者的区别 Activity.finish() Call this when your a ...
- Android Activity的生命周期简单总结
Android Activity的生命周期简单总结 这里的内容参考官方的文档,这篇文章的目的不是去总结Activity是如何启动,如何创造,以及暂停和销毁的,而是从实际开发中分析在Activity各个 ...
- Android Activity返回键控制的两种方式
Android Activity返回键监听的两种方式 1.覆写Activity的OnBackPressed方法 官方解释: Called when the activity has detected ...
- Android Activity和Fragment的转场动画
Android Activity和Fragment的转场动画 Activity转场动画 Activity的转场动画是通过overridePendingTransition(int enterAnim, ...
- android Activity生命周期(设备旋转、数据恢复等)与启动模式
1.Activity生命周期 接下来将介绍 Android Activity(四大组件之一) 的生命周期, 包含运行.暂停和停止三种状态,onCreate.onStart.onResume.o ...
- Android Activity的加载模式和onActivityResult方法之间的冲突
前言 今天在调试程序时,发现在某一Activity上点击返回键会调用该Activity的onActivityResult()方法.我一开始用log,后来用断点跟踪调试半天,还是百思不得其解.因为之前其 ...
- Android Activity的onSaveInstanceState() 和 onRestoreInstanceState()方法:
Android Activity的onSaveInstanceState() 和 onRestoreInstanceState()方法: 1. 基本作用: Activity的 onSaveInstan ...
- Android activity的回传数据
package com.example.myact3; import android.content.Intent; import android.os.Bundle; import android. ...
随机推荐
- 学JS的心路历程-函式(二)arguments
参数(argument)与函式参数(parameter) 在讨论函式时,很多人都会把这两个搞混,我自己也不例外. 虽然讲错别人也听得懂,但是我们还是要搞清楚这两个的定义到底是什么! 参数是当我们呼叫函 ...
- java中Integer和int的区别(转)
int和Integer的区别 1.Integer是int的包装类,int则是java的一种基本数据类型 2.Integer变量必须实例化后才能使用,而int变量不需要 3.Integer实际是对象的引 ...
- 历届试题 对局匹配-(dp)
问题描述 小明喜欢在一个围棋网站上找别人在线对弈.这个网站上所有注册用户都有一个积分,代表他的围棋水平. 小明发现网站的自动对局系统在匹配对手时,只会将积分差恰好是K的两名用户匹配在一起.如果两人分差 ...
- Linux系统下面crontab选择默认编译器
crontab修改默认编辑器 crontab默认编辑器为nano. 修改crontab默认编辑器为vi或者其他的编辑器. 法一: export EDITOR="/usr/bin/vim&qu ...
- Android Studio 2.3.3上引入3.0上开发的项目遇到的问题
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) debugImplementation project( ...
- 10.18号java课后动手动脑
问题一结论:类如果提供了一个自定义的构造方法,将导致系统不再提供默认构造方法. 问题二结论:(1)程序运行的结果是100和300,field=200为类的初始化块,可以在类中使用“{”和“}”将语句包 ...
- Displacement Mapping
[Displacement Mapping] Displacement Mapping(移位贴图). Normal maps的另一个应用是displacement mapping,在这个应用中,细节的 ...
- PHP实现curl和snoopy类模拟登陆方法
Snoopy.class.php下载 方法/步骤 第一种:使用snoopy类实现模拟登陆 1.在网上下载一个Snoopy.class.php的文件 2.代码实现: <?php set_t ...
- Maven 基本参数
-h,--help Display help information-am,--also-make ...
- 202. Happy Number (INT)
Write an algorithm to determine if a number is "happy". A happy number is a number defined ...