<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uni.activity"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ActivityDemoActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity01"
android:label="@string/app_name">
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/Button_A" android:text="GO to activity 2" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/Button_A" android:text="GO to activity 2" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, ActivityDemoActivity!</string> <string name="app_name">ActivityDemo</string> <string name="activity01">this is activity 01</string> </resources>
/*
* @author octobershiner
* 2011 07 29
* SE.HIT
* 演示完整的activity的声明周期,以及isFinish方法的调用
* 此activity为程序入口activity
* */
package uni.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ActivityDemoActivity extends Activity {
/** Called when the activity is first created. */
private static final String TAG = "demo";
private Button button_A;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button_A = (Button)this.findViewById(R.id.Button_A);
button_A.setOnClickListener(new myButtonListener());
}
private class myButtonListener implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(ActivityDemoActivity.this, Activity01.class);
ActivityDemoActivity.this.startActivity(intent);
//感兴趣的朋友可以取消下面的代码注释,来测试finish方法的使用,会发现第一个activity会被强制终止
//ActivityDemoActivity.this.finish();
}
};
protected void onStart(){
super.onStart();
Log.i(TAG, "The activityDemo state---->onStart");
}
protected void onRestart(){
super.onRestart();
Log.i(TAG, "The activityDemo state---->onReatart");
}
protected void onResume(){
super.onResume();
Log.i(TAG, "The activityDemo state---->onResume");
}
protected void onPause(){
super.onPause();
//调用isFinishing方法,判断activity是否要销毁
Log.i(TAG, "The activityDemo state---->onPause");
if(isFinishing()){
Log.w(TAG, "The activityDemo will be destroyed!");
}else{
Log.w(TAG, "The activityDemo is just pausing!");
}
}
protected void onStop(){
super.onStop();
Log.i(TAG, "The activityDemo state---->onStop");
}
protected void onDestroy(){
super.onDestroy();
Log.i(TAG, "The activityDemo state---->onDestroy");
}
}
/*
* @author octobershiner
* 2011 07 29
* SE.HIT
* 演示完整的activity的声明周期,以及isFinish方法的调用
* 此activity可由ActivityDemoActivity启动
* */
package uni.activity;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class Activity01 extends Activity{
private static final String TAG = "demo";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity01);
Log.d(TAG, "The activity01 state---->onStart");
}
protected void onStart(){
super.onStart();
Log.d(TAG, "The activity01 state---->onStart");
}
protected void onRestart(){
super.onRestart();
Log.d(TAG, "The activity01 state---->onReatart");
}
protected void onResume(){
super.onResume();
Log.d(TAG, "The activity01 state---->onResume");
}
protected void onPause(){
super.onPause();
Log.d(TAG, "The activity01 state---->onPause");
//调用isFinishing方法,判断activity是否要销毁
if(isFinishing()){
Log.w(TAG, "The activity01 will be destroyed!");
}else{
Log.w(TAG, "The activity01 is just pausing!");
}
}
protected void onStop(){
super.onStop();
Log.d(TAG, "The activity01 state---->onStop");
}
protected void onDestroy(){
super.onDestroy();
Log.d(TAG, "The activity01 state---->onDestroy");
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有