一个简单的页面跳转
代码
package demo.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class testmain extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.Button01);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent=new Intent();
intent.setClass(testmain.this,testchild.class);
startActivity(intent);
finish();
}
});
}
}
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class testmain extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.Button01);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent=new Intent();
intent.setClass(testmain.this,testchild.class);
startActivity(intent);
finish();
}
});
}
}
代码
package demo.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class testchild extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.child2);
Button btn=(Button)findViewById(R.id.Button01);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent=new Intent();
intent.setClass(testchild.this,testmain.class);
startActivity(intent);
finish();
}
});
}
}
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class testchild extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.child2);
Button btn=(Button)findViewById(R.id.Button01);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent=new Intent();
intent.setClass(testchild.this,testmain.class);
startActivity(intent);
finish();
}
});
}
}
代码
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="demo.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".testmain"
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=".testchild"
android:label="@string/app_name">
</activity>
</application>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="demo.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".testmain"
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=".testchild"
android:label="@string/app_name">
</activity>
</application>
</manifest>